我在 Xcode 11(一个带有 SwiftUI 的 iOS 单视图项目)中创建了一个全新的项目,并启用 Mac 作为目标设备。没有做任何其他事情,我尝试构建,我得到这个错误:
ld: warning: directory not found for option '-L/Applications/Xcode'
ld: warning: directory not found for option '-L11.0-Beta.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/uikitformac'
ld: warning: directory not found for option '-L/Applications/Xcode'
ld: warning: directory not found for option '-L11.0-Beta.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/uikitformac'
ld: warning: Could not find or use auto-linked library 'swiftUIKit'
Undefined symbols for architecture x86_64:
"__swift_FORCE_LOAD_$_swiftUIKit", referenced from:
__swift_FORCE_LOAD_$_swiftUIKit_$_MyProject in AppDelegate.o
__swift_FORCE_LOAD_$_swiftUIKit_$_MyProject in SceneDelegate.o
__swift_FORCE_LOAD_$_swiftUIKit_$_MyProject in ContentView.o
(maybe you meant: __swift_FORCE_LOAD_$_swiftUIKit_$_MyProject)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
### 环境
- macOS 10.15 Catalina 测试版 (19A487l)
- Xcode 11.0 测试版 2 (11M337n)
- Swift 5 模式
更新:这也适用于 XCode 版本 13.0 (13A233)。
对于 XCode 版本 12.0.1 (12A7300),
我刚刚将 libswiftWebKit.tbd 添加到
**Link Binary with Libraries**
(来自项目,构建阶段)并且构建成功。
见下图: