I have two projects in an Xcode workspace. I would like to add the build product of project B as a bundle resource in project A. I have already configured the scheme of project A to build project B first. Is there a proper way to do this besides simply adding the build product of project B from the file system?
4 Answers
I was able to add the product of project B into project A in the following manner. I simply dragged the product of project B from the Project Navigator into the Copy Bundle Resources pane of project A. It can be tricky as you cannot initiate the drag by selecting the icon of the product -- I succeeded only by dragging its title. It was not necessary to make project B a target dependency of target A; the build dependency can be managed instead by schemes (which was the way I originally had the workspace configured).

- 1,467
- 2
- 18
- 28
The same question is somewhat answered here: https://stackoverflow.com/a/7118177/470225. It isn't a perfect solution, but it is working for me. You can add a 'Run Script' build phase to copy the resources bundle into the app binary. Here is the script:
cp -R -f $BUILT_PRODUCTS_DIR/MyBundle.bundle $BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/
Should it be cp -R -L -f $BUILT_PRODUCTS_DIR/MyBundle.bundle $BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/
with -L
, without this, during Archive only symbolic link is copied to content folder path and app is crashing becasue don't see real resources.

- 5,039
- 36
- 35
You can go to your project A's build phases tab and add project B's product to the "Copy Bundle Resources" build phase. Make sure to add a dependency for project B.

- 8,307
- 1
- 34
- 60
-
1Unforuntately project B's product does not show up as an option as a target dependency (it is not a target of project a, it simply shares a workspace) nor is it available to be added as a bundle resource. Thanks though... trying to figure out if a product of a different project can be added as a bundle resource. – ctpenrose Jan 28 '12 at 04:23
-
If you drag project B in project A, you can select project B's targets as dependencies and resources. – Fabian Kreiser Jan 28 '12 at 06:37
-
That gets me a step closer, thanks. That allows me to add project B as a target dependency. Unfortunately, project B's product still doesn't show up as an option when I try to add a bundle resource to project A. – ctpenrose Jan 28 '12 at 07:17
-
Taking a look at the project would help.. Here is a tutorial on sub-projects: http://www.cocoanetics.com/2011/12/sub-projects-in-xcode/ – Fabian Kreiser Jan 28 '12 at 07:39
-
Another question with answer: http://stackoverflow.com/questions/4219054/xcode-adding-a-project-as-a-build-dependency – Fabian Kreiser Jan 28 '12 at 07:39
-
You helped me get as far as this last answer does already :) – ctpenrose Jan 28 '12 at 08:09