Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using static library and bundle products from Xcode 4 subproject

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.

like image 574
brianpartridge Avatar asked Dec 06 '11 16:12

brianpartridge


1 Answers

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"
like image 74
brianpartridge Avatar answered Oct 26 '22 12:10

brianpartridge