Xcode freezing up or hanging, using 100% CPU for no apparent reason?


If you have an iOS 5 device that is configured to use iOS 5′s new WiFi sync feature, and you’re experiencing high CPU when using Xcode or it becomes non-responsive (eg. Xcode gets pegged at 100% or higher for not apparent reason on an otherwise idle machine), disable WiFi sync. Once I disabled WiFi sync, the high CPU usage went away. I’m guessing that perhaps my older version of Xcode (3.2.6) is trying to sync with the device over WiFi but doesn’t quite know how to do that.

Xcode 3.2.5 Organizer hangs while importing iOS 5 debug symbols


I installed the iOS 5 GM seed onto my iPhone 4 and, as usual, I fire up Xcode & go to the Organizer window so that it can download the debug symbols for the newest iOS from my device onto my Mac. This usually takes 15 minutes or so, but this time, Xcode just hung for some reason, with the Organizer indicating that it was waiting for another symbol copy process to complete first.

After some investigating, I got the symbols downloaded and all was good again. Following is a summary of the issues I ran into and solutions:

1) The “waiting on other symbol copying…” message in the Xcode Organizer.

I’m not sure what happened for me to have more than one symbol import going on, but I believe the message was triggered by the existence of a “.copying_lock” file in the directory of the iOS version that Xcode was importing symbols for.

The symbols are all stored under /Developer/Platforms/iPhoneOS.platform/DeviceSupport and looks something like this:

total 24
drwxrwxr-x  5 root  admin  170 Mar 14  2011 3.0
lrwxr-xr-x  1 root  admin    3 Mar 14  2011 3.0.1 -> 3.0
drwxrwxr-x  5 root  admin  170 Mar 14  2011 3.1
lrwxr-xr-x  1 root  admin    3 Mar 14  2011 3.1.1 -> 3.1
drwxrwxr-x  5 root  admin  170 Mar 14  2011 3.1.2
drwxrwxr-x  5 root  admin  170 Mar 14  2011 3.1.3
drwxrwxr-x  5 root  admin  170 Mar 14  2011 3.2
drwxrwxr-x  5 root  admin  170 Mar 14  2011 3.2.1
drwxrwxr-x  5 root  admin  170 Mar 14  2011 3.2.2
drwxrwxr-x  5 root  admin  170 Mar 14  2011 4.0
drwxrwxr-x  5 root  admin  170 Mar 14  2011 4.0.1
drwxrwxr-x  5 root  admin  170 Mar 14  2011 4.0.2
drwxrwxr-x  5 root  admin  170 Mar 14  2011 4.1
drwxrwxr-x  5 root  admin  170 Mar 14  2011 4.2 (8C134)
drwxr-xr-x  3 root  admin  102 Aug 15 11:16 4.2.1 (8C148)
drwxr-xr-x  4 root  admin  136 Mar 14  2011 4.3 (8F190)
drwxr-xr-x  3 root  admin  102 Mar 28  2011 4.3.1 (8G4)
drwxr-xr-x  3 root  admin  102 Apr 20 15:24 4.3.2 (8H7)
drwxr-xr-x  3 root  admin  102 Jul 25 13:55 4.3.4 (8K2)
drwxr-xr-x  3 root  admin  102 Aug  8 11:14 4.3.5 (8L1)
drwxr-xr-x  3 root  admin  102 Oct  5 13:05 5.0 (9A334)
lrwxr-xr-x  1 root  admin   11 Mar 14  2011 Latest -> 4.2 (8C134)

In my case, I was trying to import iOS 5 symbols, and the contents of the 5.0 (9A334) directory were:

$ ls -la 5.0\ \(9A334\)/
total 0
drwxr-xr-x   3 root  admin  102 Oct  5 11:14 .
drwxrwxr-x  24 root  admin  816 Oct  5 11:14 ..
-rw-r--r--   1 root  admin    0 Oct  5 11:14 .copying_lock


  1. Quit out of Xcode,
  2. Delete /Developer/Platforms/iPhoneOS.platform/DeviceSupport/5.0 (9A334)
  3. Restarting Xcode to start the symbol import again. “Waiting” message should no longer appear when you import the symbols

2) The symbols import progress bar in the Xcode Organizer sits @ 0% progress

After fixing #1, I tried the symbol import again and no longer got the “waiting” message, but the progress bar in the Organizer stayed stuck at 0% for several minutes, which is not normal. Looking at my running processes, there were two copies of DTDKSymbolHelper running, one idle and one consuming 90% CPU. I ended up killing both, quitting out of Xcode and trying once again, and the symbols finally imported correctly.

Note that when you try to quit out of Xcode during the symbol import process, you’ll get a warning message along the lines of leaving your iPhone in some busted intermediate state (or something along those lines). I just ignored them and things progressed fine — if you are experiencing the same symptoms that I did, you should be able to quit without issues.

Updating iPhone apps to support Retina displays


The iPhone 4′s 640×960 display is night and day better than the previous generation’s 320×480 display. Supporting both is actually pretty straightforward.  The simplest thing is to do nothing: iOS 4 automagically up-sizes your image assets when running on a higher resolution display like the iPhone 4. It’ll look ok, but likely pixelated for the iPhone 4′s super sharp display.

To use higher res assets for iPhone 4, while keeping the lower res versions for earlier devices, simply add higher res images into your Xcode project with the following naming convention:


If you have an existing image named foobar.png that is 100×100, simply name the higher res 200×200 version as foobar@2x.png, add it to your project, and re-build. You don’t need to do anything else…when that app runs on an iPhone 4, if there is a @2x version of an image, that version will be loaded instead.

This document on the Apple Developer site summarizes it nicely & goes into more detail than I’ve covered here.

Resizing UILabel inside a UITable cell when doing a swipe delete gesture


When you do a right swipe gesture on a table cell in the iPhone’s Mail app, a delete button appears and the text reflows around the button, like so:

I built a similar interface that looks and functions similarly. The only problem was that when you right swiped, the delete button would appear, but the text would not reflow. Looking at the API docs, I made sure that all the subviews were added to the UITableViewCell’s contentView. I found a post on Stack Overflow that mentioned setting the contentMode property to UIViewContentModeLeft, but that didn’t work for me.

After digging around some more, I discovered that the autoresizingMask property of UILabel defaults to UIViewAutoresizingNone. When i set autoresizingMask to UIViewAutoresizingFlexibleWidth in the two UILabels (subject & body preview), they now reflow automatically when the delete button appears.

Adding random contacts and email addresses to the iPhone simulator address book


I needed some test data in my iPhone simulator’s address book to test out some functionality in the Raptr iPhone app, but adding contacts one by one would have been onerous, especially since I wanted several hundred!

Thankfully, you can programmatically add contacts to the iPhone contacts so I came up with the following snippet for a quick and dirty way to add a bunch of random contacts with random email addresses:

ABAddressBookRef addressBook = ABAddressBookCreate();

// create 200 random contacts
for (int i = 0; i < 200; i++)
	// create an ABRecordRef
	ABRecordRef record = ABPersonCreate();

	ABMutableMultiValueRef multi = ABMultiValueCreateMutable(kABStringPropertyType);

	NSString *email = [NSString stringWithFormat:@"%i@%ifoo.com", i, i];
	ABMultiValueAddValueAndLabel(multi, email, kABHomeLabel, NULL);
	NSString *fname = [NSString stringWithFormat:@"Name %i", i];
	NSString *lname = [NSString stringWithFormat:@"Last %i", i];

	// add the first name
	ABRecordSetValue(record, kABPersonFirstNameProperty, fname, NULL);
	// add the last name
	ABRecordSetValue(record, kABPersonLastNameProperty, lname, NULL);
	// add the home email
	ABRecordSetValue(record, kABPersonEmailProperty, multi, NULL);
	// add the record
	ABAddressBookAddRecord(addressBook, record, NULL);

// save the address book
ABAddressBookSave(addressBook, NULL);

// release

Put this inside -viewDidLoad or -loadView, launch the simulator and you’re set: 200 random contacts added to the simulator’s Contacts app. Make sure you remove this code snippet after you’ve run it once or you’ll keep adding random contacts. If you ever want to clear out the contacts on the simulator just go to the menu: iPhone Simulator -> Reset Content and Settings…

Go to Top