From Apple Documentation :
Main Thread Checker is a standalone tool for Swift and C that detects invalid use of AppKit, UIKit, and other APIs on the background thread. Updating the user interface in a thread other than the main thread is a common error that can lead to missed user interface updates, visual defects, data crashes, and crashes.
So, for example, an attempt to change the text property of a UILabel object UILabel the background of a thread does not work. Apple says this could lead to missed user interface updates, visual defects, data crashes, and crashes. In practice, 99% of the time, this will lead to randomly missed user interface updates and visual defects (rather than crashes).
Crashing would actually be good, because we could easily detect such misuse of UIKit , but random visual defects are much harder to detect during development. And where the Main Thread Checker comes in.
Main Thread Checker will help to use dectect UIKit in the background thread, will not solve them . Once you have discovered the use of UIKit in the background thread, you can solve it using DispatchQueue .
Again, from the Apple Documentation :
The URLSession documentation says closing closure will be called in the background thread, so this is bad, Main Thread Checker helps you determine if UIKit is used in the background thread.
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in if let data = data { self.label.text = "\(data.count) bytes downloaded" // Error: label updated on background thread } } task.resume()
Decision. Use DispatchQueue.main to perform UI updates in the main thread.
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in if let data = data { DispatchQueue.main.async { // Correct self.label.text = "\(data.count) bytes downloaded" } } } task.resume()
The solution itself has nothing to do with Xcode, it is a feature of the language. Thus, it is obvious that this was possible in previous versions of Xcode, but prior to Xcode 9 you did not have a Main Thread Checker to help you detect the problem.
As @hamish points out, you can also watch the WWDC video for a more detailed explanation.