Copy files to bundle depending on active configuration

Nick Weaver picture Nick Weaver · Mar 22, 2011 · Viewed 12.3k times · Source

is it possible to control which files are copied to the bundle depending on the active configuration? I don't want to add another target for this, so this not an option.

The real life example is a splash video which is in fact 8mb in size and is long. Every start of the app shows this video which is annoying. I don't want to break too much code so the solution is a very short splash video, which is the candidate to be copied to the bundle when the debug configuration is active.

Yes, I could make the debug video very small so it doesn't hurt if it is shipped with the release but for the sake of learning new things I need a way to control which file is copied depending on the configuration. I suppose a Run Script would do this, but maybe there is a simple solution which I don't see.

Thanks in advance!

Answer

Nick Weaver picture Nick Weaver · Apr 24, 2011

I didn't find any better solution than using a Run Script. Best reference is Copy file to the App Resources directory if debug configuration is selected.

I solved my problem with this run script:

RESOURCE_PATH=$SRCROOT/ResourcesCopiedByRunScript

FILENAME_IN_BUNDLE=splashVideo.mp4

BUILD_APP_DIR=${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}

if [ "$CONFIGURATION" == "Debug" ]; then
    cp "$RESOURCE_PATH/shortDebugSplashVideo.mp4" "$BUILD_APP_DIR/$FILENAME_IN_BUNDLE"
else
    cp "$RESOURCE_PATH/productionSplashVideo.mp4" "$BUILD_APP_DIR/$FILENAME_IN_BUNDLE"
fi