Posted by Amir
on Apr 22nd, 2011 | 24 comments
After struggling for hours to solve the various build errors with Xcode4 and Three20 (old Xcode3.2 project), and then investing additional precious time to get the Xcode4 “Archive” option to work, I decided to document my steps to who ever find it useful.
I’m aware that there are useful guides about this topic, but unfortunately I could not find a complete article that answer all the various build option errors. So hopefully this will be it… :)
First thing to notice is that there is a difference between the “Archive” option and the different “Build for X” options (e.g. for running, archiving, testing).
First thing first. Let’s get the “Build for X” option to work:
- Open your project in Xcode4 and in the “Project Navigator” view, do the following for each “Three20″ related project (e.g. Three20, Three20Core, etc):
- Click on the project.
- Select the “Build Settings” tab.
- Search for “Skip Install” setting and make sure it is set to YES for Debug, Internal and Release configuration.
- Click on the project’s target (under the TARGETS section). Make sure it is NOT the UnitTests target but rather the actual build target – and set the same YES value in the “Skip Install” setting.
Make sure to repeat these steps in each Three20 project in your project tree.
- In the “Project Navigator” view, select your project and then “Build Settings”. In the “header search paths” setting add the two following entries (with the quotes) and make it the first entries in the list:”$(BUILT_PRODUCTS_DIR)/../three20″
Make sure to set it both in release and debug configuration, and that the same build setting appear in your poject’s target (under the TARGETS section).
- Follow this link to edit the Three20 scripts to enable support for Xcode4: http://stackoverflow.com/questions/5261447/xcode-4-three20-create-ipa-archive-no-such-file-or-directory/5270483#5270483
- Go to Xcode4 Preferences (Cmd + ,) > Locations > Build Location > and select “Place build products in derived data location”.
- Build your project. This should work fine both for release AND debug configurations! If there are still build errors, see the troubleshooting section below.
Now comes the part where we make the “Archive” function to work:
- Make sure you performed the steps above and everything compiles OK.
- Go to Xcode4 Preferences (Cmd + ,) > Locations > Build Location > and select “Place build products in locations specified by targets”
- Select the Archive option – it should build OK now.
As you can notice, from now on the only thing you need to manually change before switching between “Archive” and “Build fo *” option is the “Build Location” setting in Xcode4 preference window.
- If you still getting build errors try the “Clean” action under the “Product” menu and build the project again.
- If you get the “File not found” error, make sure your import is “Three20/Three20.h” and not a direct import to a class header (e.g. “Three20/TTImageView.h”)