Created
July 30, 2021 13:44
-
-
Save vnsam/f6170985eaed674c0acafd1e413c6b48 to your computer and use it in GitHub Desktop.
Injection ||| Setup Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate: NSObject, UIApplicationDelegate { | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
#if DEBUG | |
var injectionBundlePath = "/Applications/InjectionIII.app/Contents/Resources" | |
#if targetEnvironment(macCatalyst) | |
injectionBundlePath = "\(injectionBundlePath)/macOSInjection.bundle" | |
#elseif os(iOS) | |
injectionBundlePath = "\(injectionBundlePath)/iOSInjection.bundle" | |
#endif | |
Bundle(path: injectionBundlePath)?.load() | |
#endif | |
return true | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add - `-Xlinker -interposable` in `Other Linker Flags` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add this in any of the SwiftUI previews. | |
#if DEBUG | |
@objc class func injected() { | |
UIApplication.shared.windows.first?.rootViewController = | |
UIHostingController(rootView: ContentView()) | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment