Nov 11
Xcode introduced Clang LLVM compiler integrated into the IDE. By default, these only run via Build and Analyze. However, this static analysis is insanely useful, and can catch “retain leaks” quickly. Therefore, I always analyze on every build.
If you wish to do the same, simple Get Info on the Project. Under the Build Options, check the “Run Static Analyzer” option.
Tagged with: clang • static analyzer • Xcode
Nov 07
The first task I gave myself with Celery is complete. I can now search for a food, obtain a list of foods that match my search criteria, select one and get more information. This little task allowed me to learn a significant amount including:
- Using oauth and a Cocoa library to communicate
- How to build and add third party frameworks to Xcode
- How to parse JSON using a Cocoa library
- Creation and usage of Protocols
- Usage of the NSTableView class.
The first two points have been mentioned previously. I will go into more detail about the last three in future posts.
Here is a screenshot of the application.

As you can see it is quite ugly and utilitarian. This of course is not how I plan to make the app, but just needed something to learn from. One of the beauties of using MVC, which Cocoa is really built around, I can yank the View (V) and replace it with almost no code change. Just hook up the outlets to the new UI in Interface Builder and it will continue to work as before… beautiful.
Tagged with: Celery • hotdog • JSON • MPOAuthConnection • oauth • protocol • UI • Xcode
Nov 04
I banged my head against figuring out how to make use of third-party frameworks. Unfortunately, this seems like a task that most developers expect users to instinctively know how to do and never explain it otherwise. I was somewhat frustrated and having trouble getting my project to make use of the third party Framework for both compiling and running. After some banging my head on the wall, a post on StackOverflow and a few bruises later I got it working.
The first thing that I needed to do was build the framework. The particular Framework I am using is MPOAuthConnection which provides an SVN link and a project. I, therefore, needed to build the Framework in that project. Xcode is nice enough to put Products in the item list. I simply dragged the MPOAuth.framework product from the MPOAuthConnection Project to my Celery Project. Dropping it into the Linked Frameworks section and choosing to copy the files.
Using the proper imports, this admittedly tripped me up a bit, because I was working in the project and doing “file.h” imports rather than the proper <library/file.h> imports, my project would compile.
However, I was getting odd errors on running, where it couldn’t find the files needed (and some strange memory problems). Turns out, when you add a new Framework, you also have to have the build system copy the framework into the Application product. To do this, you need right click on the target for your application, Add -> New Build Phase -> New Copy Files Build Phase. The only setting that needs to be set is the Destination must be set to “Frameworks”.

Here is the key element that I could not figure out for about an hour. You must drag the Framework from the Linked Framework to the new Build Phase you just created.

Viola! You should be set.
Tagged with: Framework • MPOAuthConnection • Xcode
Aug 29
Cocoatoa :: Snow Leopard, a bargain at twice the price!.
Sounds like Snow Leopard has lots of development improvements. I know I am particularly curious about Grand Central Dispatch, OpenCL and Xcode improvements. I’ll be finding out on Tuesday. It’s not apparent how much of these improvements will make it to the iPhone, but I’m getting interested in general Cocoa development as well.
Blocks sound interesting, and I plan on checking it out. Closures has been in serious debate for Java 1.7. So, it will be interesting to see how Blocks tackles the issue. I’m more curious as to how this will help you in your daily development cycle.
I’m having trouble finding more information about the wonderous Xcode improvements, but I did see that GCC 4.2 is standard (as a Java developer this means nothing to me) and Clang is built in (which is super cool, I have been using that). It also sounds like the Build Error window has improved, as well as code completion.
OS X has always been amazing at the price, with including an amazing developer toolset. With Snow Leopard at $29, it continues to show Apple is moving to continue improving market share.
UPDATE: M Cubed Blog has good Xcode 3.2 information.
In the world of multi-touch trackpads, Xcode isn’t being left behind and now has a few gestures of its own. Much like with other browsers, 3 finger swiping left or right will move back or forwards in the history. However, 3 finger swiping up or down now moves between the header and documentation windows, which is a great new feature and one I wish I could have on my iMac.
Beautiful.
Tagged with: snow leopard • Xcode
Aug 14
When developing you are going to do something wrong (you are, stop denying it) and generate an exception. When this happens the debug console window will appear and dump a rather large stack track of values (I’m assuming these are memory address, but have no idea how this would be useful). Above that stack trace is the reason, something like:
*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** -[Image badMethodCall]: unrecognized selector sent to instance 0xd22820′
This typically gives you enough information to figure out what the problem is. If you need the line which generated it, the method trace window can give you more information. Simply trace down until you see your code (will be in bold type). That should point you to your problem stop.

Additionally, you can break whenever an exception is thrown before the system crashes. This can, in many cases, give you a better stack trace of the exception.
Open the Breakpoints view and add “objc_exception_throw” symbol as a general breakpoint.
Tagged with: breakpoint • exceptions • Xcode
Aug 03
Quick tip on locating the physical location of a file on disk while working on it in Xcode. Simply right-click (or command-click) the title bar. This will give a list of the directory structure. Clicking on any directory will open Finder at that location.

Tagged with: Tip • Xcode
Jul 31
If you updated your iPhone to OS 3.0.1 (which you should), it will break your Xcode link to build to the device. To fix this you need to follow the instructions at:
http://adcdownload.apple.com/iphone/iphone_sdk_3.0__final/iphone_os_3.0.1_advisory.pdf
Tagged with: iphone OS • update • Xcode
Jul 18
This site by far has some of the best tweaks to Xcode I’ve seen. Coming from other development environments, there have been quite a few annoyances that I couldn’t get past, this one kills almost all of them! Long live “All-in-One View”.
http://www.mobileorchard.com/14-essential-xcode-tips-tricks-and-resources-for-iphone-devs/
Tagged with: tips • tweaks • Xcode
Jul 15
↑⌘E – Zooms the Editor In/Out. (Removes the files list above the Editor).
⌥↑⌘T – Shows the current file in the Editor in the Class group tree.
Tagged with: keyboard • Tip • Xcode
Jul 14
Here are a few keyboard shortcuts that I have learned to love:
- ESC – Kicks in Autocomplete, including a drop down list of all available properties/methods for the current symbol.
- ⌘Enter – Builds and Runs
- ⌥⌘↑ – Switches between header and source files.
Tagged with: keyboard • Xcode