swiftxcodedebugginguikitlldb

How to use LLDB (XCode) to change the view background color at runtime and update view UI on the simulator


I have this code:

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Line where the breakpoint will be placed
        view.backgroundColor = UIColor.green
    }
}

I want to add breakpoint, execute the app on the simulator, and when the execution is paused, I want to use the LLDB to change backgroundColor to blue and see the background on the simulator on blue color.

How to do that?


Solution

  • I found this solution:

    e DispatchQueue.main.async { self.view.backgroundColor = UIColor.blue }
    

    This is a good UI solution for UIkit projects without SwiftUI #Preview{}