Change code and instantly see the updates in the iOS simulator without compiling your SwiftUI app!
Inject, a Swift Package created by Krzysztof Zabłocki
InjectionIII, a macOS application for the heavy lifting (i.e. watching for modified source code and interposing the new function as if it had bee compiled into the SwiftUI app)
You can read more about the Swift Package in the following article.
I also recommend reading the book "Swift Secrets" by John Holdsworth. He is the creator of
InjectionIII (also known as "Injection for Xcode) and shares the the concept of how hot reloading for iOS development is possible in the first place!
There is plenty of reading material, so I want to show you hot reloading in action! I show you all the steps needed to instrument your SwiftUI app in my YouTube video.
- Add the Swift Package
- Import its module in the source file containing your SwiftUI view
@ObservedObject private var iO = Inject.observervariable to your SwiftUI View
.enableInjection()at the end of your view's body definition
The video skips how to install
InjectionIII.app (see here for details) but I'll show you how to use macOS application.
I also share some observations and tricks and tips!
You can find the test app on my GitHub and the commit history visualizes each step done for instrumenting the SwiftUI app for hot reloading.