Skip to content

Instantly share code, notes, and snippets.

@mpvosseller
Created January 20, 2016 04:25
Show Gist options
  • Save mpvosseller/8897b379f040e0ca1476 to your computer and use it in GitHub Desktop.
Save mpvosseller/8897b379f040e0ca1476 to your computer and use it in GitHub Desktop.
Xcode Build Phase Run Script to Disable AppTransportSecurity in DEBUG Simulator Builds
#!/bin/sh
## Disable AppTransportSecurity in DEBUG Simulator Builds
if [[ ${CONFIGURATION} == "Debug" ]] && [[ $PLATFORM_NAME == *"simulator"* ]]; then
TARGET_INFOPLIST="${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}"
## Delete NSAppTransportSecurity entry if it already exists
/usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity" "${TARGET_INFOPLIST}" 2>/dev/null
## Add NSAppTransportSecurity dictionary entry
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity dict" "${TARGET_INFOPLIST}"
## Add NSAllowsArbitraryLoads = true to the NSAppTransportSecurity dictionary
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" "${TARGET_INFOPLIST}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment