Linker Error on using AsyncHTTPClient while using Vapor inside XCode Project
nishant-dani opened this issue · 2 comments
I am linking with the Vapor library pulling in the package through Package Dependencies in xcode Project, and then in my Target I link Binary with Libraries I am linking with Vapor. Vapor itself pulls in a lot of Swift packages including AsyncHTTPClient which in turn uses SwiftNIO. Somewhere along the build process, I am getting linker error and it fails to build AsynchHTTPClient and then in turn fails to build Vapor. Any tips on how I might figure this out?
XCode version is Version 15.0.1 (15A507).
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: x86_64-apple-macosx13.0
Strangely enough the issue only shows up on the test Target, when it is it is importing XCTVapor. I looked into xcode and for the regular build it compiles using builtin-Swift-Compilation. However for the test Target it uses ld (linker) where the error shows up. It is not clear why xcode would have a different compilation process for the two Targets, and I have exhaustively compared the build settings.
I raised this issue with Vapor and they suggested raising it will AsyncHTTPClient.
Ld /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/AsyncHTTPClient_-49CA00D6DAD1AA54_PackageProduct.framework/Versions/A/AsyncHTTPClient_-49CA00D6DAD1AA54_PackageProduct normal (in target 'AsyncHTTPClient' from project 'async-http-client')
cd /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/SourcePackages/checkouts/async-http-client
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-macos10.13 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -O0 -L/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -L/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -F/Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -filelist /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Intermediates.noindex/async-http-client.build/Debug/AsyncHTTPClient\ product.build/Objects-normal/x86_64/AsyncHTTPClient_-49CA00D6DAD1AA54_PackageProduct.LinkFileList -install_name @rpath/AsyncHTTPClient_-49CA00D6DAD1AA54_PackageProduct.framework/Versions/A/AsyncHTTPClient_-49CA00D6DAD1AA54_PackageProduct -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks -Xlinker -object_path_lto -Xlinker /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Intermediates.noindex/async-http-client.build/Debug/AsyncHTTPClient\ product.build/Objects-normal/x86_64/AsyncHTTPClient_-49CA00D6DAD1AA54_PackageProduct_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -debug_variant -fobjc-link-runtime -fprofile-instr-generate -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -lc++ -lz /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIO.framework/Versions/A/NIO /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/CNIOAtomics.framework/Versions/A/CNIOAtomics /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOConcurrencyHelpers.framework/Versions/A/NIOConcurrencyHelpers /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOBase64.framework/Versions/A/NIOBase64 /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/CNIODarwin.framework/Versions/A/CNIODarwin /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/CNIOLinux.framework/Versions/A/CNIOLinux /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/CNIOWindows.framework/Versions/A/CNIOWindows /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIODataStructures.framework/Versions/A/NIODataStructures /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/DequeModule.framework/Versions/A/DequeModule /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/Atomics_301F3DE065572157_PackageProduct.framework/Versions/A/Atomics_301F3DE065572157_PackageProduct /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOCore.framework/Versions/A/NIOCore /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOEmbedded.framework/Versions/A/NIOEmbedded /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOPosix.framework/Versions/A/NIOPosix /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/Atomics_301F3DE065572157_PackageProduct.framework/Versions/A/Atomics_301F3DE065572157_PackageProduct /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/Atomics_301F3DE065572157_PackageProduct.framework/Versions/A/Atomics_301F3DE065572157_PackageProduct /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOHTTP1.framework/Versions/A/NIOHTTP1 /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/Atomics_301F3DE065572157_PackageProduct.framework/Versions/A/Atomics_301F3DE065572157_PackageProduct /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/CNIOLLHTTP.framework/Versions/A/CNIOLLHTTP /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOHTTP2-3E0E01799A9AE6A0_PackageProduct.framework/Versions/A/NIOHTTP2-3E0E01799A9AE6A0_PackageProduct /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOSSL_1A7227558E2D5E_PackageProduct.framework/Versions/A/NIOSSL_1A7227558E2D5E_PackageProduct /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOHTTPCompression-21EAEB8A2236BA36_PackageProduct.framework/Versions/A/NIOHTTPCompression-21EAEB8A2236BA36_PackageProduct /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOSOCKS_-3E0E01525182DF8F_PackageProduct.framework/Versions/A/NIOSOCKS_-3E0E01525182DF8F_PackageProduct /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/NIOTransportServices_-42398F84C6D923F5_PackageProduct.framework/Versions/A/NIOTransportServices_-42398F84C6D923F5_PackageProduct /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/Logging_35C93DA702091ECE_PackageProduct.framework/Versions/A/Logging_35C93DA702091ECE_PackageProduct /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/Atomics_301F3DE065572157_PackageProduct.framework/Versions/A/Atomics_301F3DE065572157_PackageProduct -Xlinker -dependency_info -Xlinker /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Intermediates.noindex/async-http-client.build/Debug/AsyncHTTPClient\ product.build/Objects-normal/x86_64/AsyncHTTPClient_-49CA00D6DAD1AA54_PackageProduct_dependency_info.dat -o /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Products/Debug/PackageFrameworks/AsyncHTTPClient_-49CA00D6DAD1AA54_PackageProduct.framework/Versions/A/AsyncHTTPClient_-49CA00D6DAD1AA54_PackageProduct -Xlinker -add_ast_path -Xlinker /Users/nishant/Library/Developer/Xcode/DerivedData/eipohub-apxkwtzpnwmidygvhoiftnlhxqvi/Build/Intermediates.noindex/async-http-client.build/Debug/AsyncHTTPClient.build/Objects-normal/x86_64/AsyncHTTPClient.swiftmodule
ld: Undefined symbols:
type metadata for NIOTLS.TLSUserEvent, referenced from:
AsyncHTTPClient.TLSEventsHandler.userInboundEventTriggered(context: NIOCore.ChannelHandlerContext, event: Any) -> () in AsyncHTTPClient.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Do we need to have
.product(name: "NIOTLS", package: "swift-nio"),
in Package.swift?
Hi @nishant-dani,
Yes, you are right. We are missing NIOTLS
dependency for AsyncHTTPClient
and AsyncHTTPClientTests
.
Do you think you can open a PR and add the missing dependency to Package.swift
?
Interestingly we build on CI with --explicit-target-dependency-import-check error
which should catch this mistake. This seems like a bug: swiftlang/swift#70560