How to include a bundle in main project xcode 4.1

Leonardo picture Leonardo · Jul 14, 2011 · Viewed 12k times · Source

[UPDATE 03/04/2015]

The question is now 4 years old, and applies to a specific version of XCode which I have now specified in the subject.


I have searched a lot for this argument, but I couldn't find a solution, I even post on stackoverflow, but I soon deleted the question becuase of very little access. Now I am trying again.

I have a workspace with two distinct projects A and B.

B has two targets, one that build a static library Blib.a, and one that build a bundle B.bundle. All of them get built in the derived directory.

In project A I can easily add the static library from the build phases. However I cannot find a way to include the bundle. B.bundle is not visible from "copy resource" tab in A. Therefore I need to add manually, with all that implies. I also thought about using a script, but I would like to use this as a very last option.

Has someone a solution for this ? Did I miss something ?

thanks

Answer

Leonardo picture Leonardo · Aug 19, 2011

After long investigation, it came up there's no easy way of doing this. The B.bundle is never visible to A project, and there's no settings in workspace to change that. At this point there are three solutions:

  • Include the bundle manually from "copy resources->other", I started with this, but everytime there's a change you have to drop and include the bundle again
  • Create a script to be run in build phase, if everything is built into the PRODUCTS dir you can find the bundle easily and having copied automatically into the app.bundle. This is not a bad solution. If you are using svn the script got included in project, and users have it for free without additional work.
  • As suggested by Apple tech support, use folder references.Build bundle B into a folder and add such folder to project A using the "Create Folder References for any added folders" option. Xcode 4 will update your bundle into that folder every time you built it. The added folder will appear as blue once included in your project A.

Thats's it, I personally use the script, because this solution is path independent if you use standard xcode reference variable such as BUILT_PRODUCTS_DIR and so on, and the shell script is just a cp -r-f

[UPDATE 03/04/2015]

I would like to point out that the question is now 4 years old. At that time there weren't many "official" options available. I even spoke with Apple Tech Support, which proposed solution 3 as the only available solution. It is of course very likely that things are now changed, and there is a much better solution. Just to speak, I also like to add that the three above are not "hacks" but "solutions", maybe technically outdated, but they can still be used nowadays. I intend a "hack" as a..."hack", which means it probably not going to work in future software release.