skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    This issue is resolved in Xcode 12.5 Beta 3


  2. Yes, I got the same Issue and Im struggling with it. It’s seems there is nothing wrong with your code. Probably is some permission on xcode. Be sure to have added this line in info.plist enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search