fro*_*ion 5 swift swift-package-manager corestore xcode11
我正在尝试使用 xCode11 beta 7构建具有外部依赖项 ( CoreStore ) 的swift 包。我的包针对 iOS11+,它在Package.swift以下位置声明:
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Storages",
platforms: [.iOS(.v11)],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Storages",
targets: ["Storages"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/JohnEstropia/CoreStore.git", from: "6.3.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Storages",
dependencies: [.product(name: "CoreStore")]),
.testTarget(
name: "StoragesTests",
dependencies: ["Storages"]),
]
)
Run Code Online (Sandbox Code Playgroud)
但是,当我构建它时,没有指定 iOS 版本的依赖项构建,所以我得到兼容性错误:
"'uniquenessConstraints' is only available in iOS 9.0 or newer"等等。
我该如何解决?看起来是 xCode11 错误,但我不确定。
在我的机器上,将platforms:参数添加到清单中解决了这个问题。例如:
let package = Package(
name: "MyLibrary",
platforms: [.iOS("13.0")],
// ...
Run Code Online (Sandbox Code Playgroud)
我不确定这是否是 xCode bug,但是使用 Swift Package Manager 和 xCode 11,您必须在使用#available检查时明确指定 iOS 版本。不管库是否针对 iOS 10+,而不是
if #available(macOS 10.11, *) {
info.append(("uniquenessConstraints", self.uniquenessConstraints))
}
Run Code Online (Sandbox Code Playgroud)
你应该使用
if #available(macOS 10.11, iOS 9.0, *) {
info.append(("uniquenessConstraints", self.uniquenessConstraints))
}
Run Code Online (Sandbox Code Playgroud)
拉取请求已发布: https://github.com/JohnEstropia/CoreStore/pull/341
| 归档时间: |
|
| 查看次数: |
2100 次 |
| 最近记录: |