Swift Package minimum ios version

2.5k views Asked by At

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?

2

There are 2 answers

1
Raj Sharma On

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 
}
0
lazarevzubov On

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)]
    // ...
)