Skip to content

Instantly share code, notes, and snippets.

@johnno1962
Last active November 6, 2019 23:51
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnno1962/840cf2f58420d0a4ebdad7b237e43186 to your computer and use it in GitHub Desktop.
Save johnno1962/840cf2f58420d0a4ebdad7b237e43186 to your computer and use it in GitHub Desktop.
SwiftUI Injection
// First, install InjectionIII.app from the Mac AppStore
// https://apps.apple.com/us/app/injectioniii/id1380446739?mt=12
// Make these changes to your code:
// add the following to application(didFinishLaunchingWithOptions:)
#if DEBUG
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load()
#endif
// Add this code to the end of your SwiftUI ContentView source
// using the UIHostingViewController from your Scene delegate.
class Refresher {
@objc class func injected() {
UIApplication.shared.windows.first?.rootViewController =
UIHostingController(rootView: ContentView())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment