Created
August 21, 2018 02:08
-
-
Save orgmir/553bae776bfdb0680a923c7003616377 to your computer and use it in GitHub Desktop.
Disable the AppDelegate when initializing a NSApplication for testing
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
import AppKit | |
private func isTestRun() -> Bool { | |
return NSClassFromString("XCTestCase") != nil | |
} | |
if isTestRun() { | |
// This skipping setting up the app delegate | |
NSApplication.shared.run() | |
} else { | |
// For some magical reason, the AppDelegate is setup when | |
// initialized this way | |
_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment