How can I prevent the use of the Settings.bundle command in Release build vs Debug builds?

I need to have setup.bundle in our debug build, but don't want to have it in our version. How do I approach this? Is there a script that I can use to remove it from the package resource build phase?

+6
debugging iphone release settings.bundle
source share
3 answers

You can write a script to remove the entire parameter set for a specific build configuration. For the purpose, in the "Build Settings" section, there is an option to run the script. This script should do what you need:

BUILD_APP_DIR=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app if [ "$CONFIGURATION" == "Release" ]; then rm -Rf $BUILD_APP_DIR/Settings.bundle echo "Removed Settings Bundle" fi 

The shell field can read / bin / sh

+4
source share

Found. I created RunScript as the last step in the build phases. There I delete all entries in the plist settings and replace them with the version number. That way, I can use settings.bundle root.plist as parameters for my debugging project (to determine which test server to use or any other thing that will be indicated in the debug build). So, when you create debug, root.plist is what you expect. When you run the Release build, the contents will be replaced by the CFBundleVersion information of your info.plist. All options related to debugging have disappeared.

 if [ "$CONFIGURATION" = "Release" ] ; then echo "Replacing $CODESIGNING_FOLDER_PATH/Settings.bundle for 'Release' build" APPVERSION="`/usr/libexec/PlistBuddy -c \"Print :CFBundleVersion\" \"$CODESIGNING_FOLDER_PATH/Info.plist\"`" SETTINGSBUNDLEPATH="$CODESIGNING_FOLDER_PATH/Settings.bundle/Root.plist" /usr/libexec/PlistBuddy -c "Delete :PreferenceSpecifiers" "$SETTINGSBUNDLEPATH" /usr/libexec/PlistBuddy -c "Add :StringsTable string 'Root'" "$SETTINGSBUNDLEPATH" /usr/libexec/PlistBuddy -c "Add :PreferenceSpecifiers array" "$SETTINGSBUNDLEPATH" /usr/libexec/PlistBuddy -c "Add :PreferenceSpecifiers:0 dict" "$SETTINGSBUNDLEPATH" /usr/libexec/PlistBuddy -c "Add :PreferenceSpecifiers:0:Type string 'PSGroupSpecifier'" "$SETTINGSBUNDLEPATH" /usr/libexec/PlistBuddy -c "Add :PreferenceSpecifiers:0:Title string 'Version Information'" "$SETTINGSBUNDLEPATH" /usr/libexec/PlistBuddy -c "Add :PreferenceSpecifiers:1:Type string 'PSTitleValueSpecifier'" "$SETTINGSBUNDLEPATH" /usr/libexec/PlistBuddy -c "Add :PreferenceSpecifiers:1:Title string 'Release:'" "$SETTINGSBUNDLEPATH" /usr/libexec/PlistBuddy -c "Add :PreferenceSpecifiers:1:Key string 'appVersion'" "$SETTINGSBUNDLEPATH" /usr/libexec/PlistBuddy -c "Add :PreferenceSpecifiers:1:DefaultValue string '$APPVERSION'" "$SETTINGSBUNDLEPATH" fi 
+12
source share

Alternatively, just do not include the parameter set in the β€œCopy package resources” and add the script build phase to enable it only for certain configurations.

A script is executed here, which also updates the version and embeds it in the settings

 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 

make sure you change the path of Blah/Supporting Files to what you really

0
source share

All Articles