Much has been written about managing multiple versions of Xcode. With the release of the Mac App Store, Apple changed the Xcode install process. It’s time to revisit this discussion, including installation of older Xcode versions as well as some tips on managing beta releases.
Prior to the Mac App Store, it was quite simple to work with multiple versions of Xcode, as each release had an option to specify the destination folder during install. No more, installations (non-beta) will overwrite an installed version of an app with the latest release, as each new release is installed in the /Applications folder with the name Xcode.app.
In this post I’ll walk through how I prefer to manage multiple versions of Xcode. If you have another approach, please post a comment.
Somewhere around Xcode 4.3 lldb became the default debugger. I’ve been spending some time learning how lldb differs from gdb and stumbled upon a trick to allow changing the value of a variable while in a breakpoint.
For example, in the code below I print the value of testStr, I then change its value using the expr command in lldb, I then print the value of the string again:
NSString *testStr = @"fubar";
NSLog(@"testStr before: %@", testStr);
// Set breakpoint here, run the 'expr' shown below
// Show testStr again
NSLog(@"testStr after: %@", testStr);
I’m sure you’ve noticed the innocuous little reference to CPU and Memory utiltization in Xcode 5 when running a project:
Xcode offers a handy way to highlight and edit all references to a variable within the current scope. Here are the steps:
First, make sure you have the setting shown below enabled within the Text Editing tab in the Xcode Preferences:
You can easily drag/drop a block of code in Xcode by simply marking a block, click and drag. If you look closely, within the editor window there will be vertical bar in the leftmost column that shows the insertion point.
In addition to dragging code about inside the code editor, this is also a quick way to add code to the snippet library. Simply mark, click, drag and drop a block of code onto the snippet library pane (lower right corner of the screen). Obviously, the Utilities view needs to be visible before this maneuver.
This tip I stumbled upon while in Xcode and I inadvertently double clicked on a brace and the matching brace and code sandwiched between was highlighted. Intrigued, I tried the same with parenthesis and brackets and it worked as anticipated.
Should there be no match, Xcode responds with a beep. It couldn’t be easier to find matching code delimiters in Xcode.
As an example, here is a line of code with a handful of parenthesis:
UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0
You may be familiar with the Xcode Open Quickly option, which provides a shortcut to open a file in your project via Shift-Command-O and entering a file name. This is often much quicker than searching through the Project Navigator to find a file.
How to View System Header Files
Good news is, you can also use the same process to view header system files. As an example, bring up the Quick Open dialog and enter stdio – as you type a series of matches will be shown: