This method should not be called on the main thread as it may lead to UI unresponsiveness.

I have the same problem with the main function

Post not yet marked as solved Up vote post of iOS_wzb Down vote post of iOS_wzb
24k views

Replies

DispatchQueue.main.async {

    /// do your action inside main thread (here)

}

  • not working this, it's naturally the first thing everyone does when seeing that.

Add a Comment

What I see is that SecTrustEvaluateIfNecessary is causing this. Which means a deadlock to my understanding: unless you figure out how to override certificate trust check of WKWebView to do it in background thread separately from loading web view url (needs to be on main thread).

I'm having the same problem. I've tried both DispatchQueue.main.async{} and Task{}.

Same here

same here and for any other Xcode user.

the lack of quality control at Apple is unbelievable

Same here

Same problem when I'm trying to open WKWebView on the touch to navigation item button. Xcode v. 14.0 (14A309)

Bringing so many troubles to developers.

+1 (same here, Xcode 14.2)

+1 to same issue in xcode 14.2.

Facing the same issue, please Apple response & help the developers

I had the same message but with a different code. My code was: for item in items { guard let nsImage = NSImage(data: item) else { continue }   images.append(Image(nsImage: nsImage)) }

I resolved the message error with this:

DispatchQueue.global(gps: .background).async { for item in items { guard let nsImage = NSImage(data: item) else { continue }   images.append(Image(nsImage: nsImage)) } }

Hope this helps to everybody.

Thank you @amervil !

DispatchQueue.global().async { }

That is what did it for me!

For context: I was trying to run a simple apple script with NSAppleScript(..).executeAndReturnError(). The script was working just fine, but I was also receiving several of those "This method should not be called on the main thread.." errors in the console.

I'm getting these warnings all of a sudden, despite my code not changing for years, since updating to Xcode 15.3