Take the 2-minute tour ×

Say I have 2 projects in an Xcode 4 workspace. Project A is the final product which requires the utility app built from project B. The goal is to have the build process of A automatically build project B if necessary, then copy the built app into the resource folder of product A's app bundle.

Xcode 4's documentation is really lacking in this regard. I tried adding the built B.app into project A with Add Files to "project A"... command. It does copy the app bundle but it doesn't check for a dependency. That is, it does not automatically build project B when it's updated.

Any pointer to find the right documentation is also much appreciated.

Edited: I am looking to accomplish the first 2 benefits mentioned in this doc, that are:

  • One project can use the products of another project while building.

  • If one project depends on the products of another in the same workspace, Xcode can detect this and automatically build the projects in the correct sequence.

I know the plain old project way of adding a project to another one as a sub-project so I can set the target dependencies. But from the wording of the workspace doc, there's seems to be an easier and automatic way. But I am not able to find the steps to do either of the two features.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Add project B as "Target dependency" in project A's "Build phases" tab in the target screen. (The screen that you get when you click on the top level project node)

It seems that a project can only define the output of another project as dependency if the second project is a subproject of the first:

I can define the output of Project B as dependency of A in this constellation

If your Workspace has the following structure, defining dependencies is not possible: Output of B does not show up in the dependency editor of A in this constellation

share|improve this answer
Thanks. But that's like in the plain old project way, right? I thought this new workspace thingy has a better way. In the only doc I find (developer.apple.com/library/ios/#documentation/ToolsLanguages/…) it mentions: "One project can use the products of another project while building." and "If one project depends on the products of another in the same workspace, Xcode can detect this and automatically build the projects in the correct sequence." The later obviously does not really work in my case. –  Stephen Chu Oct 31 '11 at 18:18
It seems B must be a subproject of A so that it's output shows up in A's dependency editor. I updated my original answer with screens. –  weichsel Oct 31 '11 at 18:31
Thanks for the update. I am looking for the new "magical" workspace way. But it seems Apple is just blowing hot air on this one. It's exactly the same old project way. I fail to see the benefit of using the new workspace. Xcode even messes up this old way. It doesn't add product B into the copy resource phase automatically. I have to manually build B and add B.app to A. Even then it still messes it up. I specified the released B to be copied. But when building A for debug, it builds a debug B and can't find B.app to copy since it's in a different build directory. Oh my... –  Stephen Chu Oct 31 '11 at 18:48
Yes.Organizing the project as described above was possible without the workspace feature. I also have no idea what advantages one can gain by using workspaces. –  weichsel Oct 31 '11 at 19:35

Xcode 5.1

The trick lies with User Header Search Paths. So position your projects close to each other (In the same directory is probably a good idea).

Lets say for example we had Project A and Project B in the same directory like so


  • Project A //project A related header files dir
  • projectA.xcodeproj


  • Project B //project B related header files dir
  • projectB.xcodeproj

First create your workspace. Then click and drag the Xcode proj file of project A into the workspace. Repeat this with the Xcode proj file of project B and be sure not to set up a subproject relationship i.e. don't drag project B within project A, but rather underneath it.

You should then have a workspace with project A and project B listed in the file navigator, as two independent projects that don't know about each other.

Now go to the project settings of project A and select the project target. Go to build settings and find 'User Header Search Paths'. Here will will add a recursive directory, so that project A knows about the files in project B.

To do this we need to be mindful of where those files are in relation to project A. When you think about it, you need to go up one level (..), then go over the to parent directory of project b (/ProjectB) then go down one level into the folder than has a space in its name (/Project\ B). So add the following line to your User Search Paths and don't forget to tick recursive, to include all of the sub directories

../ProjectB/Project\ B


Now you should be able to import files from Project B, into project A.

share|improve this answer

Your Answer


