On further investigation it seems that App Transport Security is now enforced for the UI test runner application in the latest beta.
To my knowledge there isn't an official mechanism to update the Info.plist of the test runner application, the Info.plist within the test target is for the UI test bundle which is embedded within the test runner application.
I did find a workaround:
Adding the following script as a Test Pre-Action in the scheme (which inherits build settings from the UI test target):
TEST_RUNNER="$TARGET_BUILD_DIR/.."
INFO_PLIST="$TEST_RUNNER/Info.plist"
# Add NSAppTransportSecurity setting to allow localhost http connections
plutil -replace NSAppTransportSecurity -json '{"NSAllowsLocalNetworking": true}' $INFO_PLIST
# Code Sign
xcrun codesign --force --sign - --timestamp=none $TEST_RUNNER
We have to manually patch the Info.plist of the test runner application after test target is built.
I understand the importance of consistency of the simulator behaviour regarding App Transport Security for all applications including the UI test runner. However it would be a real shame to lose out on the ability to make requests to local servers from within the test runner to aid and enhance the testing possibilities in Xcode.
Some suggestions on how this could be officially supported:
- Respect the settings in the UI test bundle's Info.plist
- Replicate the App Transport Security settings of the main application being tested