8

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 4

4

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).

0
3

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/
0

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.

6
  • 1
    Unforuntately 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, 2012 at 4:23
  • If you drag project B in project A, you can select project B's targets as dependencies and resources. Jan 28, 2012 at 6: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, 2012 at 7:17
  • Taking a look at the project would help.. Here is a tutorial on sub-projects: cocoanetics.com/2011/12/sub-projects-in-xcode Jan 28, 2012 at 7:39
  • Another question with answer: stackoverflow.com/questions/4219054/… Jan 28, 2012 at 7:39
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.