Symbol not found: _swift_getTypeByMangledNameInContext2

We have MacOS application which uses Network Extensions. When building it with XCode 15 and 15.0.1 the extension crashes on Intel based Macs with the following error:

Symbol not found: _swift_getTypeByMangledNameInContext2 
Expected in: /usr/lib/swift/libswiftCore.dylib

We tested it on Big Sur and Ventura with the same outcome. On Ventura when running on Intel based Mac libswiftCore.dylib really doesn't provide this symbol:

nm -g libswiftCore.dylib | grep Mangle
00007ff80faf6150 T _$ss031_getFunctionFullNameFromMangledD007mangledD0SSSgSS_tF
00007ff80fcc4460 T _swift_getFunctionFullNameFromMangledName
00007ff80fcc40b0 T _swift_getMangledTypeName
00007ff80fcf7ed0 T _swift_getTypeByMangledName
00007ff80fcf8230 T _swift_getTypeByMangledNameInContext
00007ff80fcf8370 T _swift_getTypeByMangledNameInContextInMetadataState
00007ff80fcf7d90 T _swift_getTypeByMangledNameInEnvironment
00007ff80fcf80f0 T _swift_getTypeByMangledNameInEnvironmentInMetadataState
00007ff80fcfb460 T _swift_getTypeByMangledNode

Is there any workaround for this issue?

Crash log is the following:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   dyld                            0x000000010a165f7a __abort_with_payload + 10
1   dyld                            0x000000010a18ef40 abort_with_payload_wrapper_internal + 80
2   dyld                            0x000000010a18ef72 abort_with_payload + 9
3   dyld                            0x000000010a10f14a dyld::halt(char const*) + 672
4   dyld                            0x000000010a10f274 dyld::fastBindLazySymbol(ImageLoader**, unsigned long) + 167
5   libdyld.dylib                   0x00007fff203b3376 dyld_stub_binder + 282
6   ???                             0x0000000104b086a0 0 + 4373644960
7   com.xxxx.Tunnel         0x00000001049d318a 0x10489e000 + 1266058
8   com.xxxx.Tunnel         0x00000001049df35d 0x10489e000 + 1315677
9   com.xxxx.Tunnel         0x00000001048a0765 0x10489e000 + 10085
10  com.apple.ExtensionKit          0x00007fff31bda683 __112-[EXConcreteExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke + 808
11  libdispatch.dylib               0x00007fff201ec5dd _dispatch_call_block_and_release + 12
12  libdispatch.dylib               0x00007fff201ed7c7 _dispatch_client_callout + 8
13  libdispatch.dylib               0x00007fff201f9b86 _dispatch_main_queue_callback_4CF + 940
14  com.apple.CoreFoundation        0x00007fff204ce356 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
15  com.apple.CoreFoundation        0x00007fff20490188 __CFRunLoopRun + 2745
16  com.apple.CoreFoundation        0x00007fff2048efe2 CFRunLoopRunSpecific + 567
17  com.apple.Foundation            0x00007fff21151fa1 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
18  com.apple.Foundation            0x00007fff211e0384 -[NSRunLoop(NSRunLoop) run] + 76
19  libxpc.dylib                    0x00007fff200e53dd _xpc_objc_main + 825
20  libxpc.dylib                    0x00007fff200e4e65 xpc_main + 437
21  com.apple.Foundation            0x00007fff211732bd -[NSXPCListener resume] + 262
22  com.apple.pluginkit.framework   0x00007fff2b288273 0x7fff2b26d000 + 111219
23  com.apple.pluginkit.framework   0x00007fff2b287efb 0x7fff2b26d000 + 110331
24  com.apple.pluginkit.framework   0x00007fff2b288639 0x7fff2b26d000 + 112185
25  com.apple.ExtensionKit          0x00007fff31be6d05 EXExtensionMain + 70
26  com.apple.Foundation            0x00007fff211e2479 NSExtensionMain + 208
27  libdyld.dylib                   0x00007fff203b4621 start + 1

Crash log is the following:

Please post a full crash report. See Posting a Crash Report for advice on how to do that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you for your reply.

The issue is solved.

The reason for appearing non-existing symbol was using a dependency which was targeted for macOS 14.0.

Seeing this when building swift package from command-line, but not Xcode (macOS 15, Xcode 16)

  • Put Xcode toolchain bin dir first on PATH, to use that swift
  • swift build of package
  • Not setting TOOLCHAIN

It's unclear to me how swift discovers libraries in Xcode or from the command-line, or how better to configure the swift toolchain used for command-line builds

It's unclear to me how swift discovers libraries in Xcode or from the command-line

If you’re talking about system libraries, that’s determined by the SDK root. In Xcode, this is controlled by the Base SDK build setting. Historically that might’ve included different SDK versions for any given platform. Nowadays each Xcode comes with just one SDK per platform.

When working on the command line, both xcodebuild and the various Swift tools honour the current developer tools setting. View or change this using xcode-select. Or if you just want to override it for one command, set the DEVELOPER_DIR environment variable.

Note that this selects an Xcode, which includes both a toolchain and a set of SDKs.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Symbol not found: _swift_getTypeByMangledNameInContext2
 
 
Q