I upgraded to the latest Xcode 12.5 Beta 2 today, and now all of my URLSession.dataTask requests are failing and timing out. I create a sample project that makes a simple request, but it's failing each time. It works find with Xcode 12.5 Beta 1.
Here's a simple request:
guard let url = URL(string: "https://hacker-news.firebaseio.com/v0/item/8863.json?print=pretty") else { fatalError() }
let startTime = Date()
let task = URLSession.shared.dataTask(with: url) { data, response, error in
let requestTime = Date().timeIntervalSince(startTime)
print("Time for request: \(requestTime)")
if let error = error {
updateLabel("requestTime: \(requestTime)\nError: \(error.localizedDescription)")
return
}
guard let httpResponse = response as? HTTPURLResponse,
(200...299).contains(httpResponse.statusCode) else {
updateLabel("requestTime: \(requestTime)\n\(response.debugDescription)")
return
}
if let mimeType = httpResponse.mimeType, mimeType == "text/html",
let data = data,
let string = String(data: data, encoding: .utf8) {
DispatchQueue.main.async {
print(string)
// self.webView.loadHTMLString(string, baseURL: url)
}
}
}
task.resume()
func updateLabel(_ text: String) {
print(text)
}
Is anyone else on the beta having this same issue?