DEV Community

Herlandro Hermogenes
Herlandro Hermogenes

Posted on

U𝗽𝗱𝗮𝘁𝗲 your view at runtime on the simulator using LLDB

How to use LLDB (XCode) to change the view background color at runtime and update view UI on the simulator (for projects without SwiftUI)?
Image description

  • Set a breakpoint in the same line that you want do change/update in runtime.
  • Run the app on the simulator. When the execution is paused, type this expression on the main thread in the XCode console:

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

  • Hit Enter and release the execution. You will see the background changing from green to blue on the simulator.

This is a good UI solution for UIKit projects without SwiftUI Preview

Top comments (0)