I am trying to add support for Swift Package Manager to one of my frameworks. The framework is iOS specific (I make use of UIKit on it), so I added the platforms configuration to my Package.swift file which now looks like this:
import PackageDescription
let package = Package(
name: "MyLibrary",
platforms: [
.iOS(.v11)
],
products: [
.library(
name: "MyLibrary",
targets: ["MyLibrary"]),
],
targets: [
.target(
name: "MyLibrary",
path: "Sources"),
.testTarget(
name: "MyLibraryTests",
dependencies: ["MyLibrary"]),
]
)
Even though the package builds correctly on Xcode. When running swift build in the console I get the following error.
error: no such module 'UIKit'
Adding the -v flag to make the compilation more verbose I see that it is trying to build the package for macOS and that's why it fails.
Why is it building the framework for macOS if it is not listed in platforms? is this not the way to make an iOS specific swift package?