Workspace interproject-dependencies and xcodebuild

Update 8/14/2016: I just hit this problem again and, what do you know, this blog post was the first result on a Google search for the problem. Unfortunately, the solution I landed on four years ago isn't the correct one (though it does work). Instead of going through the steps below, you simply need to be sure you are specifying the workspace when invoking xcodebuild. For example:

/usr/bin/xcodebuild -scheme "Entangler MAS" -workspace Antenna.xcworkspace -configuration Release_MAS clean build archive

Leaving this here because it is not at all obvious. If you have an Xcode workspace containing multiple projects, and a scheme in that workspace depends on targets in more than one of those projects, Xcode’s own automatic dependency detection may well work, but xcodebuild will fail. The solution:

  1. In Xcode, go to Product -> Edit Scheme.
  2. Click on Build
  3. Add each of the dependencies in the Targets box, making sure the dependent targets are listed lower than the dependencies.

I also had to uncheck the Parallelize Targets box.

Related – you will also need to make sure the Scheme you wish to build is marked Shared in the Manage Schemes UI.