Reputation: 881
I have an app with multiple build configurations. If the selected configuration is Debug, I want NSAllowsArbitraryLoads key in the Info.plist
file to be set as YES, else I want it to be set as NO.
How do I go about achieving this?
Upvotes: 4
Views: 887
Reputation: 881
The solution I found requires the use of PlistBuddy:
In your project settings, select Build Phase > click + to add a new run script build phase.
Name the phase "App Transport Security". Paste the following script:
if [ "${CONFIGURATION}" = "Release" ];
then
/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads false" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
else
/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads true" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
fi
Upvotes: 5