Search code examples
iphoneiosxcode4

Include/exclude resources depending on scheme


I have some large resources that I only need for my simulator runs—I'd like to have them automatically excluded from all device builds. Is there any way to do this with Xcode 4 short of custom build scripts that copy the resources?


Solution

  • I went with a Run Script phase with the following:

    if [ ${PLATFORM_NAME} != "iphonesimulator" ]; then 
        echo "device build -- removing resources..."
        rm "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/test_a.mp3"
        rm "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/test_b.mp3"
        # reveal the binary in the Finder
        /usr/bin/open --reveal "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
    else
        echo "simulator build..."
    fi