Swift 引发 Link 失败
0 0x10d09ebb4 __assert_rtn + 166
1 0x10d0aa7d3 ld::tool::SymbolTableAtom<x86_64>::classicOrdinalForProxy(ld::Atom const*) (.cold.2) + 35
2 0x10cf57c38 ld::tool::SymbolTableAtom<x86_64>::classicOrdinalForProxy(ld::Atom const*) + 184
3 0x10cf57120 ld::tool::SymbolTableAtom<x86_64>::addImport(ld::Atom const*, ld::tool::StringPoolAtom*) + 128
4 0x10cf56717 ld::tool::SymbolTableAtom<x86_64>::encode() + 551
5 0x10cf4855e ___ZN2ld4tool10OutputFile20buildLINKEDITContentERNS_8InternalE_block_invoke.413 + 30
6 0x7ff81a1b6ac6 _dispatch_call_block_and_release + 12
7 0x7ff81a1b7dbc _dispatch_client_callout + 8
8 0x7ff81a1c7359 _dispatch_root_queue_drain + 1014
9 0x7ff81a1c784f _dispatch_worker_thread2 + 152
10 0x7ff81a355b43 _pthread_wqthread + 262
A linker snapshot was created at:
/tmp/XXXXX.debug.dylib-2024-09-18-143728.ld-snapshot
ld: Assertion failed: (it != _dylibToOrdinal.end()), function dylibToOrdinal, file OutputFile.cpp, line 5184.
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
在使用XCode16 编译时,在Link 时,出现了上述错误,排查了几天,才发现是Swift 引起的。
项目中最初为适配Swift 混编加入了以下配置。
在XCode16上
项目配置文件中
LD_RUNPATH_SEARCH_PATHS 去掉 usr/lib/swift
LIBRARY_SEARCH_PATHS
去掉 (PLATFORM_NAME)
(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
正常编译