Reputation: 597
I've created my package which I would like to use in my projects. In the package, I'm using UIStackView. When I adding the package to the project and running it I get errors 'UIStackView' is only available in iOS 9.0 or newer. Why I get this error if my project iOS target sitting set to 9.0? How can I solve this problem without making iOS 8 support in the package?
Upvotes: 5
Views: 2703
Reputation: 2285
Supported platforms and their versions can be added by platforms
parameter of Package
initializer inside the Package.swift file:
let package = Package(
name: "Package Name",
platforms: [.iOS(.v13)]
// ...
)
Upvotes: 8
Reputation: 1137
UIStackView introduced in iOS 9 so if your project supports iOS 8 too then UIStackView will be not available for iOS 8. So add check like below
if #available(iOS 9, *) {
//UIStackView code
} else {
// any other alternative
}
Upvotes: 2