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.
The Swift Package Manager can be used to add external libraries in Xcode projects. This makes the tool a good alternative to Cocoapods and Carthage for managing the dependencies of an iOS project.
Swift Package Manager includes a build system that can build for macOS and Linux. Starting with Xcode 11, Xcode integrates with SwiftPM to provide support for including packages in iOS, macOS, watchOS, and tvOS applications.
Manual Dependency ManagementOpen the new Alamofire folder, and drag the Alamofire. xcodeproj into the Project Navigator of your application's Xcode project. Select the Alamofire. xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.
Also known as SwiftPM or SPM, it's been included in Swift since version 3.0. From the official repository: The Swift Package Manager is a tool for managing distribution of source code, aimed at making it easy to share your code and reuse others' code.
On my machine, adding the platforms:
parameter to the manifest solved it. For example:
let package = Package(
name: "MyLibrary",
platforms: [.iOS("13.0")],
// ...
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With