What’s the correct way to configure Xcode 4 workspaces to build dependencies when needed?

Editing the scheme (swapping around build targets, un-/check “Parallelize Build” and/or “Find Implicit Dependencies”) didn’t work for me. I still had to clean build the project, after any code change in the static lib. Searching the dev forums, I finally found this answer, which worked wonders.

Make sure the Identity and Type inspector is showing and select the libWhatever.a file in your application’s project (not the library). If you see Location: Relative to Project [or Relative to Group], this is your problem.

  1. Click Relative to Project and change it to Relative to Build
    Products.
  2. This will change the type of the link, but it will still
    be broken.
  3. Click the locate button and find the output file.

Adding a static lib to an existing project via Build Phases -> Link Binary with Libraries automatically makes it “Relative to Group” (if both are siblings in the same workspace). Changing its location the way described above resolves the build dependency problem and in the project navigator your .a file should appear in black letters (instead of red).

Leave a Comment

tech