Import Swift Package with higher Deployment Target


I am currently trying to use iOS 13 features and frameworks in a project that has a minimum deployment target of iOS 12.
If I want to use eg. SwiftUI in that project, I can easily import the SwiftUI framework and use @available and #available statements to check if iOS 13 is available and use SwiftUI if thats the case.

However, if I try to do the same with a swift package that only supports iOS 13 and newer, importing that framework does not work.
What I've tried so far is to set the framework as optional inside "Link Binary with Libraries" to weak link it and used a canImport statement when trying to import the package framework.
Sadly both options did not work. Is there an option so that importing a swift package works also if the deployment target isn't high enough?

1 Like