Created
October 21, 2022 16:43
-
-
Save V8tr/d584af8f87f827c2d6c01598fa195393 to your computer and use it in GitHub Desktop.
Disables App Transport Security for debug builds in Xcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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