I'm seeking advice on how to share assets between 4 targets in my project: A.app, B.app, C.app, D.app
Approach 1 - Best case. I have attempted this unsuccessfully
- Create an Assets.bundle target.
In the 'Run Script' phase, copy files from Assets.bundle into the *.app targets, like this:
cd "${BUILT_PRODUCTS_DIR}" ls Assets.bundle | sed '/Info.plist/d' | xargs -t -I {} cp -r Assets.bundle/{} "${CONTENTS_FOLDER_PATH}/"
However when I run the app, the UI looks wrong. The .xib's gets loaded, but no images gets loaded! The image files and nib files seems to have been copied correct into the .app folder. My hypothesis is that a compiled .nib file assumes that it's located inside the Assets.bundle folder, thus explaining why it doesn't work when it's located outside the Assets.bundle folder.
Am I missing something in this approach?
Approach 2 - Untested
Make a Assets.xcconfig file that is #imported by the {A,B,C,D}.app targets.
Approach 3 - Untested
Mirror the 'Copy Bundle Resources' from the A.app target to the {B,C,D}.app targets
With a ruby script I can update the 'project.pbxproj' file.
Approach 4 - My current approach
Maintain 'Copy Bundle Resources' manually on {A,B,C,D}.app targets.
EDIT: I want to abandon this 'Target Membership' approach, because it's a big project and multiple people are contributing.
Approach 5 - Worst case
- Create an Assets.bundle target.
- Copy the Assets.bundle folder into the *.app targets.
- Change all [NSBundle mainBundle] code, so it uses the Assets.bundle instead.
In this project I have >1000 image files and >150 .xib files. There is much legacy code that uses hardcoded path lookups. Rework will take time. I have done this change on small project. This is a very elegant solution. However a rework of this size will take lots of time.