Important information, I am running all this under a TestCase.
My URL is http://my-MacBook-Pro.local:8080/myapi/v2/Driver/getDriver?domain=123&driver=125&key=9808098
If I paste this URL on Safari
running on the same iPhone Simulator
. It responds with the JSON. I noticed my catalina.out reported this request.
I have enabled Allow HTTP Services
on Settings->Developer
.
This is the code snippet
print("fullurl ->"+urlComponents.url!.absoluteString)
URLSession.shared.dataTask(with: urlComponents.url!, completionHandler: {
(data, response, error) in
if(error != nil){
print("error")
}else{
do{
let json = try JSONSerialization.jsonObject(with: data!, options:.allowFragments) as! [String : AnyObject]
print (json)
}catch let error as NSError{
print(error)
}
}
}).resume()
EDIT
Reference
Added the following to info.plist
, still my http request did not get thru to my localhost
mac running tomcat on port 8080
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>My-MacBook-Pro.local</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
EDIT
Tried even with these settings in info.plist
. No impact. Did a Clean
, yet no impact.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Something wrong with my code I guess.