Skip to content

Instantly share code, notes, and snippets.

@V8tr
Created October 21, 2022 16:43
Show Gist options
  • Save V8tr/d584af8f87f827c2d6c01598fa195393 to your computer and use it in GitHub Desktop.
Save V8tr/d584af8f87f827c2d6c01598fa195393 to your computer and use it in GitHub Desktop.
Disables App Transport Security for debug builds in Xcode
#!/bin/sh
# disable_ats_debug.sh
INFO_PLIST="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
PLISTBUDDY="/usr/libexec/PlistBuddy"
if [ "${CONFIGURATION}" == "Debug" ]; then
$PLISTBUDDY -c "Add :NSAppTransportSecurity dict" "${INFO_PLIST}" || true
$PLISTBUDDY -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" "${INFO_PLIST}" || true
$PLISTBUDDY -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads true" "${INFO_PLIST}"
else
$PLISTBUDDY -c "Delete :NSAppTransportSecurity:NSAllowsArbitraryLoads" "${INFO_PLIST}" || true
fi
ALLOWS_ARBITRARY_LOADS_ENABLED=$($PLISTBUDDY -c "Print :NSAppTransportSecurity:NSAllowsArbitraryLoads" "${INFO_PLIST}")
if [ "${ALLOWS_ARBITRARY_LOADS_ENABLED}" == "true" ]; then
echo "Warning: :NSAppTransportSecurity:NSAllowsArbitraryLoads set to true (potentially insecure)."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment