Skip to content

Instantly share code, notes, and snippets.

@soxjke
Created November 1, 2017 14:02
Show Gist options
  • Save soxjke/fd3f899f8d1a4c0b258292a9ca563725 to your computer and use it in GitHub Desktop.
Save soxjke/fd3f899f8d1a4c0b258292a9ca563725 to your computer and use it in GitHub Desktop.
Test-aware app launch
import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let _ = AppStore.shared
let _ = LocationService.shared
let _ = WeatherService.shared
AppStore.shared.producer.logEvents().start()
return true
}
}
import UIKit
var appDelegateClassName =
(nil != Bundle.allBundles.first { $0.bundlePath.contains(".xctest") }) ?
NSStringFromClass(TestAppDelegate.self) :
NSStringFromClass(AppDelegate.self)
let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(to: UnsafeMutablePointer<Int8>.self,
capacity: Int(CommandLine.argc))
UIApplicationMain(CommandLine.argc, argv, nil, appDelegateClassName)
import UIKit
class TestAppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment