A couple weeks ago, a gentlemen named Timothy Collins called into the Vergecast podcast and sent the blogosphere into a tizzy by suggesting how Apple could increase the screen size in a new iPhone by simply elongating the screen to a 16:9 (ish) ratio, while keeping the same resolution (326 dpi)….
Some time ago I registered Allan Odgaard’s excellent TextMate with the intention of switching from programming in Xcode to programming in TextMate (building the application from TextMate using the Xcode command line support). Since then I have been using TextMate for all kinds of text processing work (HTML, XML, etc.), all but Objective-C programming.
This week I finally started to dig into using TextMate with Xcode…
According to the TextMate manual there are two options for migrating from Xcode: 1. Drag and drop the folder containing the Xcode project on to the TextMate application. 2. Use the Xcode bundle’s import function to import a Xcode project.
First, I gave option 1 a try because option 2. according to the manual, does have some drawbacks, but I will get to that later. After dragging and dropping the folder, a project was created within TextMate with the full folder structure including all files are directories. Building and running the project went fine. The included subversion bundle seems to recognize all the changes I made to the source code. Double-clicking a .nib file opened up Interface Builder nicely. Great! Then I started tidying up the project structure as I don’t want to see my full folder structure (including build and .lproj folders, images, etc.). I wanted to group the source logically per area (views and controls, controllers, Core Data classes, etc.). This did not turn out to be so easy: deleting references to the files in the project structure only works temporary as they reappear after some time? TextMate allows you to group files and folders together, but, groups can not be placed in a folder (which makes sense in a way). There is a possibility to filter the contents of a folder using regular expressions. The works fine is you want to filter certain file types but excluding individual files is a pain.
Ok, let’s give option 2 a try…
Importing the Xcode project from the bundle’s menu worked painlessly. The structure of the TextMate project nicely resembles the structure I had with Xcode. There are no folders, only groups. I can now reorganize the groups in any way I like. Great. Building and running the project also works fine. Double-clicking a Nib group(!) seems to do nothing! Ouch!. Removing the group and dragging in the Nib from disk solved that problem (the Nib became folder) by doing this).
Ok, what about subversion. Subversion does not work anymore. It only recognizes the changes for the Nib file (folder actually) I just added to the project. Bummer. The problem, from reading TextMate’s documentation, is the value of the
TM_PROJECT_DIRECTORY variable which is set to the first folder in the project. The only folder I have is the Nib I copied in earlier. Everything else is a group. In order to get subversion to work I have to add the folder with all my sources and the Xcode project to the top of the TextMate project. Doing so solved the subversion problem. If I want to see all uncommitted changes for the project, I just select the top folder and press shift-control-A-0.
The following screenshot shows the final project structure. I have also added the ‘common’ folder which contains the working copy of some shared code I use among projects.
One drawback of having the source code folders next to the group structure, I found out later, is that finding text within the project is taking a really long time as it searches through the folder structure and the group structure. In the end I decided to add a file and folder pattern (folder’s ‘Show information’ context menu option) of ‘!*$’ which basically means ‘do not show anything’ (I really only want the top folder, not the contents of the folder).
Have fun with TextMate and Xcode!