我正在尝试从命令行手动链接一些快速代码。这是我在做什么:
ld \
-syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk \
-lSystem \
-arch x86_64 \
-macosx_version_min 10.15 \
-o ./bin/main \
-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx \
main.o
但是失败,显示以下输出:
ld: warning: Could not find or use auto-linked library 'swiftCore'
ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find or use auto-linked library 'swiftFoundation'
ld: warning: Could not find or use auto-linked library 'swiftDarwin'
ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find or use auto-linked library 'swiftIOKit'
ld: warning: Could not find or use auto-linked library 'swiftXPC'
ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
ld: warning: Could not find or use auto-linked library 'swiftDispatch'
如果我使用usr / lib / swift-5.0而不是usr / lib / swift,则可执行文件会抱怨dylib无法在10.14.4之前的OS X上使用。
我在这里想念什么?你能帮我吗?预先感谢!
答案 0 :(得分:1)
可以通过在 Xcode 中添加 “swift file” 和 “Create Bridging Header” 来修复此错误。
请按照以下步骤解决此问题。