Add Unit Tests to an Xcode 4 Project Created in Xcode 3

Adding unit tests in Xcode 4 is easy if you want to use OCUnit. Instructions to do this can be found here. This post assumes that you have created an Xcode 3 project with default settings and want to create application tests for it in Xcode 4. When you open this project in Xcode 4 and try to run your unit tests, you will get a Mach-O linker error. For example, if you have a class named AppDelegate located in AppDelegate.h, this error will occur when you try to #import the AppDelegate.h file to make use of your AppDelegate class in your unit tests. This is because in Xcode 3, the default build setting in your application target for Strip Debug Symbols During Copy is Yes for both Debug and Release builds. You want this to be No, at least for your Debug builds. You can keep this setting as Yes for release builds if you want to limit the chances of someone reverse engineering your application. The blog post Tired of getting Mach-O Linker errors when unit testing? by Drew Crawford was very helpful when dealing with this issue.

Advertisements
This entry was posted in Open Source and tagged , . Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s