Created
March 30, 2017 18:39
-
-
Save sundeepgupta/8a1c10406c0935edc66e16e57f612078 to your computer and use it in GitHub Desktop.
Dynamically swap AppDelegate at runtime for unit testing in Swift
This file contains 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
let appDelegateClass: AnyClass? = NSClassFromString("TEST_TARGET_MODULE_NAME.TestAppDelegate") ?? AppDelegate.self | |
let classString = NSStringFromClass(appDelegateClass!) | |
let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv) | |
.bindMemory(to: UnsafeMutablePointer<Int8>.self, capacity: Int(CommandLine.argc)) | |
UIApplicationMain(CommandLine.argc, argv, nil, classString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment