Using static library and bundle products from Xcode 4 subproject
Asked Answered
B

1

9

I have a workspace containing 2 projects:

  1. A project that has 2 products: a static library and a resource bundle
  2. A project that builds an iOS app.

The first project has been added as a subproject reference under the second project. I have the static library building fine, it links into the app, all is well. However, I cannot seem to include the resource bundle in the app.

The bundle has been added to the app's 'Build' scheme.

I've tried dragging the Resources.bundle into the app's 'Copy Build Resources' phase, but that results in this error at build time:

.../DerivedData/MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug-iphonesimulator/Resources.bundle: No such file or directory

So I looked at the derived data directory and I see Resources.bundle in

MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug 

not

MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug-iphonesimulator.  

I assume this is because the bundle isn't platform specific. So I tried added a build phase to copy the bundle to the Products Directory. Resulting in this build error:

.../DerivedData/MyProject-eyuldesiktlginanzifvzcfrtmgl/Build/Products/Debug-iphonesimulator/Resources.bundle depends on itself.  This target might include its own product.

But there is no Debug-iphonesimulator/Resources.bundle file, so I don't see where this dependency is coming from. Any advice would be greatly appreciated.

Bighead answered 6/12, 2011 at 16:40 Comment(0)
B
7

I figured it out. The problem is (as mentioned above) that the bundle isn't platform specific so it outputs to to the Products/Debug directory while the app outputs to the Products/Debug-iphonesimulator directory. I had to add a Run Script phase to copy the resource into the app bundle:

SRC="$BUILD_DIR/$CONFIGURATION/Resources.bundle"
DEST="$BUILD_DIR/$CONFIGURATION$EFFECTIVE_PLATFORM_NAME/$FULL_PRODUCT_NAME"
cp -R "$SRC" "$DEST"
Bighead answered 7/12, 2011 at 15:32 Comment(2)
Can you please explain me how to add this run script?Giuliana
This is really awesome. Actually I am trying to locate my SRC to "~/Xcode/DerivedData/MyTarget-blydmmnwjukedcdoelnbylneztfd/Build/Products/Debug-iphonesimulator" but here it gives "~/Xcode/DerivedData/MyTarget-blydmmnwjukedcdoelnbylneztfd/Build/Products/Debug". Could you please help me with this ?Giuliana

© 2022 - 2024 — McMap. All rights reserved.