Xcode workspaces with sub-projects and project dependencies triggering builds

前端 未结 6 414
轻奢々
轻奢々 2021-01-31 08:18

I wish there was better documentation for this for Xcode 5 but I couldn\'t find anything decent describing best practices for working with workspaces, so..

In a workspac

相关标签:
6条回答
  • 2021-01-31 08:37

    Just in case somebody else is having problems with this in Xcode 7: Make sure the project you want to add as subproject it's not open, before you add it or drop it.

    0 讨论(0)
  • 2021-01-31 08:40

    You could create a scheme that builds all targets.

    0 讨论(0)
  • 2021-01-31 08:40

    This is derived from Tomte's answer. His approach was causing me a Dependency Analysis Error. This is a more straight forward approach and explains why Tomte's answer works:

    1. Click on the sub-project and drag it into the project that needs to target the sub-project.
    2. The options alert should now be displayed. Make sure Copy items if needed is not selected. Make sure Create groups is selected. Make sure none of the project's targets are selected. Press the Finish button.
    3. Click on the project that you just added the sub-project reference to.
    4. Click on the target that you want to have a dependency on the sub-project.
    5. Click the Target Dependecies + button.
    6. Notice the sub-project's product is listed as an option. Select it.

    Note that when using Tomte's approach, when the project is added to Link Binary With Libraries, a project reference is created. This project reference can be found in the Frameworks group of the project.

    I'm conflicted as to whether this is a good approach or not. The scheme approach is not much better, in my opinion. I'm actually wondering why workspace project's don't have this relationship by default.

    At the very least, this should clear up the magic in Tomte's solution.

    0 讨论(0)
  • 2021-01-31 08:42

    Consider migrating to CocoaPods.

    Not only it will fix your build problems, but with a project as complex as you describe it will ease your life when updating/adding/removing frameworks, changing target system version and resolving dependencies and conflicts.

    Also your workspace will likely become only two projects.

    0 讨论(0)
  • 2021-01-31 08:45

    This solution was intended for another problem, but maybe it fills your needs.

    After adding your subproject to the workspace:

    1. Select the Target which should use the newly added subproject
    2. In "Link Binaries with Libraries" under Build Phases hit the + button
    3. If the Library does´t show up hit "Add Other..."
    4. Navigate to the Folder where the project file (*.xcodeproj) lies
    5. Mark it and hit "Open"
    6. Now you should see the Project File show up under "Link Binaries with Libraries"
    7. Under "Target Dependencies" in the same tab, hit the + button
    8. Now you should see the necessary files
    9. Check yours and hit "Add"
    10. Again in the "Link Binaries with Libraries" hit the + button
    11. Now your .a file should show up and you can choose and add it

    Now you are using the chosen library for your target. Repeat those steps for every target which needs this subproject. Hope that helps! For me it did because i could not manage to add dependencies to it before...

    Greetz, Tomte

    0 讨论(0)
  • 2021-01-31 08:58

    In Xcode 5 you have to:

    • Select the project on the left tab
    • Choose the target in the TARGETS section
    • Then in Build Phases > Target Dependencies press "+"
    • Choose the added project as target it will appear in the Target Dependencies list

    If it works, when building all target dependencies will be build together if needed.

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