Xcode workspaces with sub-projects and project dependencies triggering builds

Jay picture Jay · Oct 7, 2013 · Viewed 36.4k times · Source

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 workspace with several projects (couple frameworks, 1 app) is it possible to have Xcode build all dependent projects only when required (i.e. changes found) w/o having to include all projects in all dependent projects?

I'd rather like to just have the frameworks in the project depending on it instead of having 5-6 sub projects in it as this is just a mess in the Navigation View -
files inside sub-projects show up in search results all the time, sub-projects in the NavView expand for whatever reason within projects..

However, w/o including projects a particular project depends on I couldn't find a way to have Xcode 5 re-build the frameworks automatically if one of the dependencies has changed.

Answer

Tomte picture Tomte · Mar 24, 2014

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