我使用的 Swift Package Manager 没有与之关联的 xcodeproject 文件,并且在通过终端构建时出现错误。当我调用该swift build命令时,我收到一条错误消息,指出 MacOS 构建失败。我正在构建的包不支持 MacOS(它使用 UIKit),但只支持 iOS。我想不出一种方法来调用命令来只指定构建是针对 iOS 的。我已经谷歌搜索了,但没有运气。如果存在从终端为 iOS 构建 SPM 包,有人知道正确的语法吗?
我使用的 Swift 版本是:“Apple Swift 版本 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)”
我已经在 Package.swift 文件中指定了平台
let package = Package(
name: "Package",
platforms: [.iOS(.v10), ],
products: [
...
Run Code Online (Sandbox Code Playgroud)
我在 github https://github.com/mike011/Swift-Package-Manager-Example上创建了一个示例项目。当我运行swift build它失败
/git/Swift-Package-Manager-Example/Sources/Swift-Package-Manager-Example/iOSSpecificFile.swift:9:8: error: no such module 'UIKit'
import UIKit
^
/git/Swift-Package-Manager-Example/Sources/Swift-Package-Manager-Example/iOSSpecificFile.swift:9:8: error: no such module 'UIKit'
import UIKit
^