Skip to content

Instantly share code, notes, and snippets.

@paulfreeman
Forked from IanKeen/EntryPoint.swift
Created July 7, 2020 18:05
Show Gist options
  • Save paulfreeman/9fb08325fefd77a486e1dbe7f35480ba to your computer and use it in GitHub Desktop.
Save paulfreeman/9fb08325fefd77a486e1dbe7f35480ba to your computer and use it in GitHub Desktop.
Example main.swift
NSSetUncaughtExceptionHandler { print("🧨", $0) }
let isUITesting = /* your UI test detection here */
let isUnitTesting = NSClassFromString("XCTest") != nil
let noTests = !isUnitTesting && !isUITesting
let delegate = isUITesting
? NSStringFromClass(UITestAppDelegate.self)
: noTests ? NSStringFromClass(AppDelegate.self)
: nil
print("🚀 Using AppDelegate:", delegate as AnyObject)
let argc = CommandLine.argc
let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv)
.bindMemory(to: UnsafeMutablePointer<Int8>?.self, capacity: Int(CommandLine.argc))
UIApplicationMain(argc, argv, nil, delegate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment