I have the same problem with the main function
This method should not be called on the main thread as it may lead to UI unresponsiveness.
+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