2.tools-PlistBuddy
the plist buddy is convince for us operator the plist file in Xcode, we can use the plist buddy command set/add/delete the plist key-value, and wrapper it in the build phases shell scripts
description:
/usr/libexec/PlistBuddy --help
Set :CFBundleIdentifier com.apple.plistbuddy
//Sets the CFBundleIdentifier property to com.apple.plistbuddy
Add :CFBundleGetInfoString string "App version 1.0.1"
//Adds the CFBundleGetInfoString property to the plist
Add :CFBundleDocumentTypes: dict
//Adds a new item of type dict to the CFBundleDocumentTypes array
Add :CFBundleDocumentTypes:0 dict
//Adds the new item to the beginning of the array
Delete :CFBundleDocumentTypes:0 dict
//Deletes the FIRST item in the array
Delete :CFBundleDocumentTypes
Deletes the ENTIRE CFBundleDocumentTypes array
# Disable File Sharing for app store builds
if [ "$BuildCondition" = "APP_STORE" ]
then
/usr/libexec/PlistBuddy -c "Set :UIFileSharingEnabled false" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
echo "Disabled file sharing (UIFileSharingEnabled) in ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
else
/usr/libexec/PlistBuddy -c "Set :UIFileSharingEnabled true" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
echo "Enabled file sharing (UIFileSharingEnabled) in ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
fi