Posts tagged with: three20

Reduce Three20 Compile Time for iOS (Making Static Libraries)

In using Three20 with Xcode 4, I have found life to be a little more difficult than in Xcode 3.

Project changes have required me to fiddle with the project/target compile settings in order to get my project to build correctly, often seeing the dreaded “Three20/Three20.h” file not found error, and not being able to build for archive have all been recurring issues that I’ve faced while developing some pretty simple iOS apps utilizing the Three20 project.

Finally, when the project is building correctly, I spend almost all my compile time building all the Three20 libraries. In search of a better way I stumbled upon a stackoverflow question, and then later on a blog post that have essentially gotten rid of all these hassles for me.

Step 1: How to build any library for all platforms

  • Open an existing static library project.
  • Select the project file on the top, and then select the target you want to build.
  • Go into the Build Phases section
  • Add a new “Run Script” build phase
  • In this phase, paste the following script:

The following code, which was copied directly from the blog post linked above, tells Xcode to compile all the targets for both Device and Simulator. The resulting output will be a .a library file for use in other projects.

Applying this to Three20

  • Go into {Three20 Root Directory}/src/Three20 and open Three20.xcodeproj
  • Select the Three20 target and add the above script into the appropriate build phase
  • Nothing needs to be done to the “Three20UnitTests” target, we won’t be using it for anything.
  • Expand the Dependencies folder for your Three20 project, in the files list on the left side of Xcode
  • Add the same script phase you did before in all of these dependent projects.
  • Do this for every dependency project. If you don’t do this, Xcode will produce all .a libraries, but only the main Three20 library will be created for all devices and they all need to be created for all devices.
  • Once you have added the script build phase to all projects and dependencies, build the project (and be patient).

Giving Due Credit

Had I not stumbled onto Christos Sotiriou‘s blog post I probably could never have figured this out from end to end on my own. He even offers a direct download to compiled libraries and headers if you want to just get up and running.


Three20 and Xcode 4 – How to solve Three20.h not found

Update: 18-Feb-2012

Even after the upgrade I have found that certain builds and project settings were flaky. To improve your build speed and reduce all the configuration hassles of using Three20 and Xcode 4 together, check out my latest blog post on Building Static Libraries

Update: 05-Feb-2012

After upgrading to Three20 1.0.6.2 and following the basic install instructions here, I had no problem building without changing any project settings. Your mileage may vary, however.

I’d still consider myself rather novice to the world of iOS development and the transition from Xcode 3 to Xcode 4 has thrown me for a loop in a few areas. I’ve grown to like storyboards and find Xcode as an IDE to be getting better, but there are some things that drive me nuts. For instance, spending the better part of a day trying to figure out how to get Three20 to work in my project (that was working JUST fine under Xcode 3!).

First!

Follow the instructions provided by Three20 to get yourself oriented with what is going on.

Getting the Build Option to Work:

  • In the Project Navigator view, do the following for each of the Three20 projects (e.g. Three20, Three20Core, etc):
  • Click on the project
  • Go to Build Settings
  • Go to the Deployment section and make sure Skip Install is set to YES for all the configurations (Debug, Internal, Release)
  • Click on the project’s target (under the Targets section) and double check that Skip Install is set to YES for each configuration as well
  • Make sure to repeat these steps in each Three20 project in your project tree

Configuring Build Settings

  • In the Project Navigator view, select your project and then Build Settings
  • Add the two following entries to the Header Search paths and make them the first entries in the list:
    • $(BUILT_PRODUCTS_DIR)/../three20
    • $(BUILT_PRODUCTS_DIR)/../../three20
  • Make sure to set it both in Release and Debug configurations, and that the same build settings appear in your project’s target

Setting the Build Location

Go to Xcode4 Preferences [Cmd + ,] > Locations > Derived Data > Advanced and select Place build products in derived data location.

Clean your project, then build it. Voila.