Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy files to bundle depending on active configuration

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!

like image 702
Nick Weaver Avatar asked Mar 22 '11 09:03

Nick Weaver


3 Answers

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
like image 124
Nick Weaver Avatar answered Oct 08 '22 08:10

Nick Weaver


The best way to do it using Exclude Source File Names under Build Settings as it shown in the image.

enter image description here

like image 40
Ramis Avatar answered Oct 08 '22 07:10

Ramis


If you can give the two different files the same name, you can put them in the build products folders for the appropriate configuration. Then add one of them to the project, and make it a reference relative to the build product.

If you want to have the files live elsewhere, you can put symbolic links in the build products folders. But I'm not sure if it would work if the files have different names but the symlinks have the same name.

I've done this trick on Mac projects, I'm assuming it would work for iOS too.

Edit: Here's an example of something I've done: I want the debug build of my app to link against the debug build of a certain library, and I want the release build of the app to link against the release build of the library. So I put the debug library (or a symlink to it) into the Debug subfolder of the app build folder, and I put the release library into the Release subfolder of the app build folder. Then, when I add the library to the project, I specify that the reference is "relative to build product".

like image 32
JWWalker Avatar answered Oct 08 '22 07:10

JWWalker