2

I recently updated xCode to version 7 and it appears that the update broke the $.ajax() call in a Cordova applicatoin. I used HTTP scoop to try to see what type of call was being made to attempt to debug, but it does not look like it is even trying to make the web service call. I know this application worked prior to the XCode (and iOS) update.

The web service is using HTTP and I did see some talk about that no longer being allowed in iOS9. I attempted to add the 'NSAllowArbitraryLoads=true' string to my info.plist file but that does not appear to make a difference.

Thanks in advance!

Nate23VT
  • 423
  • 8
  • 27

1 Answers1

2

Did you add this correctly? Xcode 7 will use iOS 9 and that won't allow HTTP backend calls by default unless overridden using NSAllowsArbitraryLoads as you stated. (Note you had it spelled incorrectly as NSAllowArbitraryLoads with an 's' missing)

Here's a working example of the change to your app's info .plist:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

And here's a script you could use as a pre build hook for iOS to do this automatically:

#!/bin/bash

echo "Adjusting plist for App Transport Security exception." val=$(/usr/libexec/plistbuddy -c "add NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" platforms/ios/PROJECTNAME/PROJECTNAME-Info.plist 2>/dev/null) echo "Done"

Just swap out PROJECTNAME for the name of your project.

gblazex
  • 49,155
  • 12
  • 98
  • 91
Simon Prickett
  • 3,838
  • 1
  • 13
  • 26