Hot-Reloading — Swift and SwiftUI

Vikash Anand
4 min readApr 18, 2022


This article is about Hot-Reloading and how we can use it to speed — up our application development workflow.

Before that lets understand, how Hot-Reloading speeds up the workflow ?

App development is an iterative process where we do code changes and then to check the outcome, we have to compile, build, run and navigate / re-navigate to the screen where we were previously in the app and then re-produce the required data to show in the app.

This whole cycle(compile, build, run, re-navigate and re-produce the required data) takes a lot of time.

Hot-reloading solves this problem. It’s about getting rid of the re-compiling of the app as much as possible. You just have to save the changes and the changes will be automatically reflected in the already running application.

Hot reloading is a technique allowing you to get rid of compiling your whole application and avoiding deploy/restart cycles as much as possible, all while allowing you to edit your running application code and see changes reflected as close as possible to real-time.


See a demo video here

Hot-Reloading works for following apple ecosystem’s UI frameworks

  1. UIKit / AppKit
  2. SwiftUI

Now lets see the steps required to integrate Hot-reloading in develpoment workflow

Add Inject SPM dependency

  • Add “-Xlinker -interposable” (without the double quotes) to the “Other Linker Flags” of all targets in your project for the Debug configuration.

Usage with UIkit / AppKit

  • Import Inject
  • Wrap the view controller / inside the ViewControllerHost / ViewHost


let viewController = YourViewController()

rootViewController.pushViewController(Inject.ViewControllerHost(viewController), animated: true)


let viewController = Inject.ViewControllerHost(YourViewController())

rootViewController.pushViewController(viewController, animated: true)

Source —

Usage in SwiftUI

  • Add @ObservedObject private var iO = variable
  • call .enableInjection() at the end of your body definition

Installation of InjectionIII app

You can get the latest release of the InjectIII from here-

  • A zip file will be downloaded, un-zip it and then place it under to “/Applications” folder.
  • Also, make sure that Xcode is also present at its default location i.e in “/Applications/”.
  • Run the “Injection” app and then select open project / open recent from its menu and pick the right workspace file you are using.

Note — After running the app, a needle / Injection icon will appear in the status bar.

  • Run you application and after your application starts running in the simulator, you will be able to see the “InjectionIII connected” log in the Xcode’s console and the Injection app icon in the status bar will turn orange now.
  • Now go ahead and do your code changes and save it (cmd + s). You should be able to see the outcome of you code changes in the simulator without stopping and re-running the app.


That’s it for now, thanks for reading. Also if you really find this helpful then please leave some applause to this article 😀😀😀.


‎Swift Secrets ‎Computers & Internet · 2021

Github Repositories Urls