Archiving a project containing Swift static libraries is broken in Xcode 10 beta 3

Radar: 41773389 (submitted by a colleague, reposting here)


Summary:


Archiving a project that includes a Swift static library referencing ObjC types within system frameworks (e.g. NSObject, NSURLSessionDelegate) causes udefined symbol errors (e.g. Undefined symbols for architecture arm64: "l003", referenced from:...) when linking in Xcode 10 beta.


Steps to Reproduce:


  • Create a new Xcode project (sample attached)
  • Create a new (Swift) static library (either .a or .framework wrapper with Mach-O Type set to Static Library)
  • Ensure the main application target links in the static library
  • Within the static library attempt to subclass or conform to an ObjC system framwork type (e.g. NSObject, NSURLSessionDelegate)
  • Archive the project


Expected Results:


Project should archive successfully (like it did when using Xcode 9)


Actual Results:


A linker error occurrs:


Undefined symbols for architecture arm64: "l003", referenced from: _$S18StaticSwiftLibrary02MyaC5ClassCMn in libStaticSwiftLibrary.a(StaticSwiftLibrary.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)


Version/Build:


Version 10.0 beta 3


Notes:


  • We're seeing various "l00x" codes based on which type is used in the static library
  • This occurs with both the old and new build system


The radar has a full sample project attached. For the purposes of this post, the Swift static library just needs to contain this:


public class MyStaticLibraryClass: NSObject {
   
}


$ swift-demangle S18StaticSwiftLibrary02MyaC5ClassCMn
$S18StaticSwiftLibrary02MyaC5ClassCMn ---> nominal type descriptor for StaticSwiftLibrary.MyStaticLibraryClass


So we're guessing the type info for the class is trying to reference some kind of auto-generated incremening L00X symbol representing any ObjC types used, or something?

Replies

Thanks for the bug report. There was a problem with some Swift symbols getting incorrectly stripped out. We'll have a fix in an upcoming beta.

Seems to be broken in Xcode 10 beta 4 as well.

Yeah, the fix didn't make it in time for beta 4. The next one should have it.

Looks like the fix is in beta 5.