Xcode 4.2 – using source code branches and other Xcode shortcuts

command T — to open a new tab in Xcode.  Tabs can be pulled outside the main tab to create a multi-window environment.  These additional windows can then be pulled over to a second monitor.  The Xcode | Settings | Behavior pane can be used to setup window layouts to automatically launch when performing certain activities (like debugging, building, or testing).

Run multiple instances of your project simultaneously:  Xcode 4.2 supports launching multiple instances of an app (or multiple apps).  This helps with testing client-server scenarios and multi-user peer-to-peer apps.  You can mix and match simulator versions and physical device types, or just run multiple instances of the same version.

running Xcode from the command line:
$ /Xcode/usr/bin/clang -c myfile.h
$ /Xcode/usr/bin/clang++ -c another_file.cpp

Source control and multiple branches: From Organizer | Repositiories you can navigate into the Branches folder under a project, and the select the + Add Branch icon to create a new branch (additional options appear in popup dialog boxes).  From within your Xcode Workspace and the Editor, activate the “Show the Version Editor” icon (it’s in the upper right area of the toolbar).  Now you’ll have a navigator bar display at the bottom of each editor pane, and you can use this navigator bar to view items in various branches.

Note: navigating in the Version Editor does not switch your currently actively branch.  Be sure to use the Organizer’s Repository view to switch branches.  When clicking the Version Editor icon, it will initially display the currently active branch and version in the lower navigation bar (in case you need to quickly verify which branch you are working in).

To switch your active editing to a different branch, navigate back to the Organizer | Repositories and select the blue folder under your project repository (left side of screen).  From here, the lower area of the Repository view will display icons to Pull, Commit, or Switch Brach.  The upper right hand portion of the Repository view will display “Current Branch: yourBranchNameHere“.  If you switch branches while a workspace has that project open, the workspace window will refresh and load the selected branch’s files into the navigator.

Reconciling code from multiple branches:  When using the Version Editor, the navigation bar in the lower area of screen “appears” to allow you to look at two branches simultaneously.  At least for me (and my installation of Xcode 4.2.1), that doesn’t actually work.  The version editor is limited to viewing within the currently active branch.   Instead, when you need to compare across branches (or are ready to merge), it seems necessary use the Xcode | File | Source Control | Merge menu option.  This will launch you into a another popup window version of the version editor; however, it will only show the most recent version in each branch (the other version navigation features are disabled in the Merge view).

I’ll update these notes if I find a better way to compare versions across multiple branches or if this is updated/fixed in a subsequent release of Xcode.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s