Xcode 10 beta 6 missing swift libs from test targets

Number:rdar://43701006 Date Originated:2018/08/24
Status:Open Resolved:
Product:Xcode Product Version:10
Classification: Reproducible:Always
Xcode fails to copy necessary Swift runtime library to unit test target

Steps to Reproduce:
Open attached project in Xcode 10.
Select scheme "TestApp"
Run tests

Expected Results:
Unit tests execute successfully

Actual Results:
Running tests reports "xctest (82603) encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. Underlying error: Test runner exited before starting test execution.)"

In the console when the failure occurs:
2018-08-22 15:31:54.501373-0700 xctest[82622:2014335] (dlopen_preflight(<path to my unit test target>): Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib

Xcode 10 beta 6 (10L232m)



Apple Developer Relations August 30 2018, 12:47 PM This appears to be happening because the Pulley framework your test bundle depends on requires a different set of Swift libraries than the test bundle itself does, and the project is configured to only look at the test bundle and its embedded contents when determining which Swift libraries to make available. You could potentially fix this by having the Swift libraries also be embedded in the dependent framework (via the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES build setting), or by embedding Pulley.framework into your test bundle via a Copy Files run phase.

Tracy Keeling August 31 2018, 9:27 AM I tried adding a dependency on on the Pulley framework, but the error still occurs. I also tried linking TestAppTests with Pulley directly, but that didn't seem to help either. Setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES in the Pulley framework to YES does seem to work. This is not ideal, though, for an app that has a lot of frameworks (embedding swift libs into each framework adds significant size to the app).

Apple Developer Relations September 3 2018, 5:53 PM Engineering has the following feedback for you: A build-time dependency on Pulley.framework is not sufficient. You will need to embed Pulley.framework into TestAppTests (e.g. with a Copy Files build phase) for its Swift stdlib dependencies to be picked up.

Tracy Keeling September 4 2018, 8:28 AM Sorry, I did embed it. The only way I could get it to work was if I both embedded the Pulley framework AND set "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES" on Pulley to YES.

Apple Developer Relations September 5 2018, 1:50 PM You’ll either need to match up the SWIFT_VERSION across your project or use ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES as mentioned. We changed the Pulley framework to use SWIFT_VERSION=4.2, upgraded the project, built, and tested your app successfully. This isn’t the best behavior, but mismatching Swift versions can be a bit finicky.

Tracy Keeling September 7 2018, 8:01 AM Pulley doesn't build with Swift 4.2 out of the box. If I update all of the targets to be version "Swift 4" I still get the same error.

Apple Developer Relations September 10 2018, 3:50 PM If you can’t update Pulley to Swift 4.2, then you need use the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to override the behavior of Xcode and copy the libraries in.

Tracy Keeling September 10 2018, 4:12 PM I figured out a way to do that only in Debug mode so as not to bloat our app when compiled in Release mode. However, I still feel like this is a valid bug in Xcode 10.

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!