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

后端 未结 4 1732
滥情空心
滥情空心 2020-11-29 18:48

My case is simple, a workspace with two sibling projects: one main (iOS) app and a project that builds several static library targets used by the app.

Here\'s how I

相关标签:
4条回答
  • 2020-11-29 19:13

    Try dragging the library project into the main project:

    library project reference inside main project

    0 讨论(0)
  • 2020-11-29 19:17

    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).

    0 讨论(0)
  • 2020-11-29 19:19

    I described the way I've been setting up multiple projets in a workspace here: http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/

    I agree that manually adjusting the build target order in the scheme should be unnecessary, based on Xcode's documentation, but that's the best solution I've found so far.


    Edit: Whenever possible I recommend using https://github.com/CocoaPods/CocoaPods to manage project dependencies at this point.

    0 讨论(0)
  • 2020-11-29 19:19

    In my case, the only way i could have that sibling configuration build is by manually adding the path "../MyLibProject/build/Debug-iphoneos" (checking recursive just to make sure) in my Build Settings -> Library Search Paths. Adding the .a file in the Main project alone didn't prevent the "lib not found" error at link time.

    0 讨论(0)
提交回复
热议问题