How can I conditionally include a file based on build configuration in Xcode?

后端 未结 6 1730
时光取名叫无心
时光取名叫无心 2020-12-07 08:06

I have an Xcode project with a large number of targets where I would like to include a settings bundle for apps built under the Ad-hoc and Debug configurations, but not unde

6条回答
  •  半阙折子戏
    2020-12-07 08:29

    I finally figured it out.

    For each target for which you want to conditionally include the settings bundle, choose its Project from the source list, choose the target, and switch to the "Build Phases" tab.

    Click the "Add Build Phase" button and choose "Add Run Script".

    Then enter the following for the script:

    if [ "${CONFIGURATION}" == "Debug" ]; then
        cp -r "${PROJECT_DIR}/Settings.bundle" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app"
    fi
    

提交回复
热议问题