升级到Swift 5后,我用来构建SwiftPM可执行文件的命令失败:
$ swift build --disable-sandbox -c release -Xswiftc -static-stdlib
ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx'
ld: warning: Could not find auto-linked library 'swiftCore'
ld: warning: Could not find auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find auto-linked library 'swiftDarwin'
ld: warning: Could not find auto-linked library 'swiftFoundation'
ld: warning: Could not find auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find auto-linked library 'swiftIOKit'
ld: warning: Could not find auto-linked library 'swiftObjectiveC'
ld: warning: Could not find auto-linked library 'swiftDispatch'
Undefined symbols for architecture x86_64:
"_$s10Foundation10NSNotFoundSivg", referenced from:
_$s5Basic5RegExV11matchGroups2inSaySaySSGGSS_tF in RegEx.swift.o
[...]
在Swift 5中为SwiftPM可执行文件构建二进制发行版的推荐方法是什么?
删除-Xswiftc -static-stdlib
参数似乎很好。这是首选方法吗?
$ swift build --disable-sandbox -c release # seems to work