Skip to content

Instantly share code, notes, and snippets.

@robnadin
Created September 3, 2015 10:57
Show Gist options
  • Save robnadin/637cfcbdab5ac04ac6f1 to your computer and use it in GitHub Desktop.
Save robnadin/637cfcbdab5ac04ac6f1 to your computer and use it in GitHub Desktop.
Xcode 7 run script phase to exclude a specific domain from App Transport Security via user-defined build settings
if [ "$ALLOW_INSECURE_HTTP_LOADS" = "YES" ]; then
PLIST_BUDDY="/usr/libexec/PlistBuddy"
cd "${TARGET_BUILD_DIR}"
DOMAIN_PATH=":NSAppTransportSecurity:NSExceptionDomains:${INSECURE_SERVER_HOST}"
$PLIST_BUDDY -c "Delete ${DOMAIN_PATH}" "${INFOPLIST_PATH}"
$PLIST_BUDDY -c "Add ${DOMAIN_PATH} dict" "${INFOPLIST_PATH}"
$PLIST_BUDDY -c "Add ${DOMAIN_PATH}:NSExceptionAllowsInsecureHTTPLoads bool true" "${INFOPLIST_PATH}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment