Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 bundle resources building phase?

like image 927
Tycho Pandelaar Avatar asked Mar 24 '11 14:03

Tycho Pandelaar


People also ask

How do I change my build settings in Xcode?

Choose the project in the Project Navigator on the left. Select the Configurations target from the Targets section and click the Build Settings tab at the top. The Build Settings tab shows the build settings for the Configurations target. It's possible to expand this list with build settings that you define.

How do I reset Xcode project settings?

To reset a single project setting so that it's no longer bold, select the option in the project settings and hit the delete key.


1 Answers

Found it. I've created a RunScript as the last phase in my build phases. In there, I remove all entries in the settings plist and replace it with a version number. This way, I can use the settings.bundle root.plist as settings for my debug project (to be able to define which test server to use or any other thing that would be specify-able in a debug build). So, when you build debug, the root.plist is what you expect it to be. When you run the Release build, the contents get replaced with the CFBundleVersion information of your info.plist. All debug related choices are gone.

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
like image 166
Tycho Pandelaar Avatar answered Oct 05 '22 20:10

Tycho Pandelaar