I have a React Native app that builds and works fine in Xcode14. I've been working on updates to the codebase so that we can use Xcode15. We have a build phase script that sets the ATS values in the Info.plist file for different configurations. This script runs fine when building in Xcode14, but does not in Xcode15 - and I am not sure why or how to fix it. Below is the script:
#Disables ATS in debug builds.
INFOPLIST="${TARGET_BUILD_DIR}"/"${INFOPLIST_PATH}"
case "${CONFIGURATION}" in
"Release"|"QA"|"Analytics")
/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSExceptionDomains:localhost:NSExceptionAllowsInsecureHTTPLoads NO" "${INFOPLIST}"
;;
"Debug")
/usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSExceptionDomains:localhost:NSExceptionAllowsInsecureHTTPLoads YES" "${INFOPLIST}"
;;
esac
This is the error I get when it fails in Xcode15:
Info.plist
Set: Entry, ":NSAppTransportSecurity:NSExceptionDomains:localhost:NSExceptionAllowsInsecureHTTPLoads", Does Not Exist
File Doesn't Exist, Will Create: /Users/xxx/Library/Developer/Xcode/DerivedData/myapp-bzgzsmndokcjuiejapqykiczhwlf/Build/Products/Debug-iphonesimulator/myapp.app/Info.plist
Command PhaseScriptExecution failed with a nonzero exit code
I'm unsure how to fix this issue or what could be the root cause. I used echo to see the path of where the Info.plist file lives, and they are the same in both Xcode14 and 15, which is /Users/xxxx/Library/Developer/Xcode/DerivedData/myapp-bzgzsmndokcjuiejapqykiczhwlf/Build/Products/Debug-iphonesimulator/myapp.app/Info.plist
I've also tried updating the Disable ATS script to check if values exist before setting, and create the values if they do not, and that resulted in the same error. Any help or thoughts would be much appreciated.