Is there any way to conditionally import a framework in Swift
based on runtime iOS version?
In particular, I have an app with a deployment target of
You can make the Framework optional (details and image from Ray Wenderlicht):
This, combined with your use of @available, should prevent the system from trying to load it on the devices where it is not available.
You need to use
#if canImport(YourFramework)
import YourFramework
#endif
instead of @available now, after setting your framework as optional :-)