1

I have a script added as a run script in Build Phases that tries to modify the Application Transport Security configuration. The script seems not working with the Xcode New Build System. In particular, when I executed the app in Simulator (DevelopmentDebug) I still have an ATS error.

Have you ever encountered the same issue?

echo "Run Application Transport Security script for ${CONFIGURATION}"

if [[ ${CONFIGURATION} == "DevelopmentDebug" || ${CONFIGURATION} == "DevelopmentRelease" ]]; then
    # Delete any existing NSAppTransportSecurity configurations
    /usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"

    # Add the NSAppTransportSecurity dictionary again
    /usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity dict" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"

    # Add NSAllowsArbitraryLoads and set it to true
    /usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
    # Add NSAllowsArbitraryLoadsInWebContent and set it to true
    /usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoadsInWebContent bool true" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
fi

# Print Info.plist result
/usr/libexec/PlistBuddy -c "Print" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
Lorenzo B
  • 33,216
  • 24
  • 116
  • 190

0 Answers0