Reputation: 658
I'm trying to build swift package with external dependency (CoreStore) with xCode11 beta 7. My package is targeted for iOS11+, it's declared in 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"]),
]
)
However, when I build it dependency builds without iOS version specified, so I get compatibility errors:
"'uniquenessConstraints' is only available in iOS 9.0 or newer"
and so on.
How can I fix it? Looks like it's xCode11 bug, but I'm not sure.
Upvotes: 12
Views: 9978
Reputation: 534885
On my machine, adding the platforms:
parameter to the manifest solved it. For example:
let package = Package(
name: "MyLibrary",
platforms: [.iOS("13.0")],
// ...
Upvotes: 10
Reputation: 64
First, you need to add a platform
parameter and fill it out with the supported platform versions. Then, you need to clear derived data
in your host app. After that, try adding the spm framework again.
I had the same thing where I didn't add the platform parameter at first and it was giving me so many "'xxx' is only available in iOS 9.0 or newer" errors in my host app. Hopefully that fixes it for you.
Upvotes: 2
Reputation: 658
I'm not sure is it xCode bug or not, however with Swift Package Manager and xCode 11 you have to clearly specify iOS version when use #available
check. Not matter if library is targeted for iOS 10+ or not, instead of
if #available(macOS 10.11, *) {
info.append(("uniquenessConstraints", self.uniquenessConstraints))
}
you should use
if #available(macOS 10.11, iOS 9.0, *) {
info.append(("uniquenessConstraints", self.uniquenessConstraints))
}
Pull request was posted: https://github.com/JohnEstropia/CoreStore/pull/341
Upvotes: 2