Don't launch simulator when running unittests

前端 未结 6 1437
悲哀的现实
悲哀的现实 2020-12-07 17:44

Some background:

I have iOS application with a target configured to run unitTests. And I am running build automation tool jenkins on my MacBook whic

6条回答
  •  甜味超标
    2020-12-07 18:04

    A osx test target can become a huge hassle because you have to manage yourself which source file to include. Putting @testable import YourAppName on top of your XCTest files is way more convenient. So just prevent your app from launching in case of a XCTest run.

    In your AppDelegate put: (Swift 3 solution)

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
    {
        if ProcessInfo.processInfo.environment["XCInjectBundleInto"] != nil {
            return false
        } 
    
    ...
    

    This wont prevent the simulator from launching, but will save you a lot of time.

提交回复
热议问题