Last active
August 29, 2015 14:21
-
-
Save dani-mp/fdb81a8e28c1b414b85d to your computer and use it in GitHub Desktop.
AppDelegate to run unit tests faster 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
1. Comment out @UIApplicationMain in your AppDelegate. | |
2. Create main.swift file with the following code: | |
import Foundation | |
import UIKit | |
let isRunningTests = NSClassFromString("XCTestCase") != nil | |
if isRunningTests { | |
UIApplicationMain(Process.argc, Process.unsafeArgv, nil, NSStringFromClass(TestingAppDelegate)) | |
} else { | |
UIApplicationMain(Process.argc, Process.unsafeArgv, nil, NSStringFromClass(AppDelegate)) | |
} | |
3. Create TestingAppDelegate.swift with the following code: | |
import UIKit | |
class TestingAppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
} | |
4. In your AppDelegate, create the window, assign its root view controller and make it key and visible. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment