Swift 引發(fā) 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 時,出現(xiàn)了上述錯誤型型,排查了幾天,才發(fā)現(xiàn)是Swift 引起的全蝶。
項目中最初為適配Swift 混編加入了以下配置闹蒜。
在XCode16上
項目配置文件中
LD_RUNPATH_SEARCH_PATHS 去掉 usr/lib/swift
LIBRARY_SEARCH_PATHS
去掉 (PLATFORM_NAME)
(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
正常編譯