How can I prevent using the Settings.bundle in Release build v.s. Debug build?

前端 未结 3 724
北恋
北恋 2021-02-09 07:07

I need to have a settings.bundle in our debug build, but don\'t want to have it in our Release. How do I approach this? Is there a runscript I can use to remove it from the copy

3条回答
  •  一向
    一向 (楼主)
    2021-02-09 07:26

    Alternatively, just don't include the settings bundle in the "Copy Bundle Resources" and add a build phase run script to only include it for certain configs.

    Here's a run script that also updates a version and build in the settings bundle

    if [ ${CONFIGURATION} == "Debug" ] ; then
        echo "Copying settings bundle..."
        version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$SRCROOT/Blah/Supporting Files/Info.plist")
        build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$SRCROOT/Blah/Supporting Files/Info.plist")
        cp -r "${PROJECT_DIR}/Blah/Supporting Files/Settings.bundle" ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
        echo "Updating settings bundle version to ${version}b${build}"
        /usr/libexec/PlistBuddy "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Settings.bundle/Root.plist" -c "Set :PreferenceSpecifiers:17
    :DefaultValue $version($build)"
    fi
    

    making sure to change out the Blah/Supporting Files path to whatever yours actually is

提交回复
热议问题