Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Brand new Xcode unit test target cannot run because "Launch session expired before checking in."

I have added a brand new unit test target to my macOS app project in Xcode. It contains the default two files:

  • (name of target).swift
  • Info.plist

However when I run my test suite, this brand new target breaks with the error "Test operation failure: Launch session expired before checking in."

The full log is:

12:12:49.492 Xcode[10034:721978] Beginning test session MyTargetTests-3902F95F-20F9-4E6C-94EE-0BF8660D3B5A at 2017-06-18 12:12:49.492 with Xcode 8E3004b on target <DVTLocalComputer: 0x7fcc3cf024d0 (My Mac | x86_64)> (10.12.4 (16E195))
12:12:49.492 Xcode[10034:721978] Launching with Xcode.DebuggerFoundation.Launcher.LLDB
12:12:49.492 Xcode[10034:894962] Waiting for connection to unix domain socket at /tmp/XCTest-QcErkZ.
12:12:59.747 Xcode[10034:721978] Launch session started.
12:12:59.832 Xcode[10034:721978] Adding console adaptor <IDEConsoleAdaptor: 0x7fcc2cd44d00 'target'> for test session 3902F95F-20F9-4E6C-94EE-0BF8660D3B5A.
12:12:59.914 Xcode[10034:721978] Test process runnable PID is 19198.
12:13:02.025 Xcode[10034:721978] Test operation failure: Launch session expired before checking in.
12:13:02.025 Xcode[10034:721978] _finishWithError:Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Launch session expired before checking in." UserInfo={NSLocalizedDescription=Launch session expired before checking in.} didCancel: 1

My setup is:

  • Mac Mini mid 2011
  • macOS 10.12.4
  • Xcode 8.3 (tried with Xcode 8 too - no good)

I have tried:

  • sudo /usr/sbin/DevToolsSecurity --enable - no good
  • Deleting and recreating the test target - no good
  • Upgrading Xcode to 8.3 - no good
  • Running the target's tests just by themselves - no good, no extra logs either

So... How do I make the unit test target work?

like image 475
chriskilding Avatar asked Dec 08 '22 17:12

chriskilding


1 Answers

The error message "launch session expired before checking in" is a bit of a red herring. You need to expose the real underlying error message, which you can access via View -> Debug Area -> Show Debug Area (if it is not already showing).

In my case, the problem was that libswiftswiftononesupport.dylib was not being linked to certain libraries of my own in my macOS app (dyld image not found). The solution was a bit weird, and laborious, but it does work:

  • I replaced all my dynamic library targets with framework targets
  • I enabled "Always Embed Swift Standard Libraries" in the framework targets
  • I did not embed the frameworks in any host application - I chose 'none' for this option.
like image 173
chriskilding Avatar answered Jan 19 '23 01:01

chriskilding