"Always Embed Swift Standard Libraries" doesn't always embed them...

Originator:jalkut
Number:rdar://30832923 Date Originated:03-Mar-2017 11:59 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Version 8.3 beta 3 (8W132p)
Classification:Serious Bug Reproducible:Always
 
Summary:
When the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES setting is specified for a target, the CopySwiftLibs build phase does a good job of analyzing the build target and copying only the pertinent Swift libraries in. In the event NO Swift dependencies are found, nothing is copied.

This is usually good, but falls short in scenarios where Swift dependencies are deeper than the immediate list of linked libraries. For example, when a linked library is itself dependent on a library that depends on Swift.

Practically speaking, this is not a problem for apps because an app must ultimately bundle all the frameworks it depends upon, including any 2nd-level dependencies. In this case the CopySwiftLibs phase locates the 2nd-level dependencies, deduces its Swift dependency, and copies in the appropriate Swift libraries.

In the case of Unit Test bundles, however, there is typically no notion of embedding frameworks, but a framework being tested may still have a Swift dependency. If the framework's Swift dependency is immediate, CopySwiftLibs finds and copies the required Swift libraries, but if the Swift dependency is 2nd-level or deeper, the Swift libraries are not copied and the Unit Test bundle fails at runtime.

Steps to Reproduce:
1. Open attached SwiftEmbeddingFailure.xcodeproj
2. Build & Test the SwiftEmbeddingFailure target

Expected Results:
The test target, depending only upon SwiftEmbeddingFailure.framework, should be given runtime access to the Swift libraries depended upon by SwiftContainingFramework.

Actual Results:
Because SwiftEmbeddingFailure.framework does not itself depend directly on Swift, no Swift libraries are copied and the unit test invocation fails.

Version:
Version 8.3 beta 3 (8W132p)

Notes:
I think that the CopySwiftLibs should follow library dependencies all the way down the chain, at least as the dependencies are not system standard frameworks. This would ensure that the linked libraries of the target in question have all of their Swift dependencies fulfilled whether they are directly or indirect.

Configuration:


Attachments:
'SwiftEmbeddingFailure.zip' was successfully uploaded.

Comments


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!