Linking a static library to an iOS project in Xcode 4

I do this as follows:

  1. Drag in the static library project. If you have the static library project open in Xcode, close it now.
  2. Select the main project in the project navigator (the project I’m adding the static library to) and in the editor, under the header TARGETS in the left-hand column, select my main project’s target and navigate to the Build Phases tab.
  3. Click the “+” for Target Dependencies and add the library icon target dependency from the added static library project.
  4. Click the “+” for Link Binary with Libraries and add the library icon that is under the folder “Workspace”.
  5. It may also be necessary to enter a Header Search Path for the headers of the static library project if that is how the headers are linked in the static library project itself.

If you don’t see the static library project as nested under the main project in the main project’s project navigator, the most likely reason for that is that the static library’s own Xcode project is still open. Quit Xcode and open up the main project that has the nested static library project in it without opening up the original static library project itself, and you should see it appearing as a nested project in your main project.

Leave a Comment