I have an application that uses iOS, todayExtension and watchOS as targets.
Until the launch of the new iOS 13, everything was working fine, that week I downloaded the iOS 13 beta on my iPhone and the watchOS 6 on my watch. Then, suddenly my app stopped working on the watch. When I put it on debug, I saw that none of my URLSession requests were being completed. Did something huge changed?
class func verifyInternet(errorHandler:@escaping (String) -> (), completionHandler:@escaping (JSON) -> ()) {
let myUrl = URL(string: "https://google.com/")
var request = URLRequest(url:myUrl!)
request.httpMethod = "GET";
request.httpBody = nil
request.cachePolicy = URLRequest.CachePolicy.reloadIgnoringLocalCacheData
let task = URLSession.shared.dataTask(with: request as URLRequest, completionHandler: {
data, response, error in
if error != nil
{
errorHandler(error.debugDescription)
return
}
if response.debugDescription.contains("Status Code: 200") {
completionHandler("connection ok")
return
}
if response != nil, let jsonString = JSON(parseJSON: response!.description) as? JSON {
//convert the JSON to raw NSData
do {
let json = try jsonString //JSON(data: dataFromString)
if json.dictionary?.keys.first?.contains("error") ?? false {
errorHandler(json.dictionary?.values.first?.stringValue ?? "error")
}
completionHandler(json)
} catch {
print("Error \(error)")
}
}
})
task.resume()
}
This is actually some of my code that on OS 5 worked nicely and on OS 6 (Simulator and Watch) doesn't (I already tried marking the option "Run independent from iPhone" also). I would paste here the error I'm getting but when I run my code on Watch simulator the debugger isn't printing anything :).