2
votes

I want to use a module (SwiftyStoreKit) which has a minimum requirement of WatchOS 6.2, however I don't want to increase my WatchOS target because I don't want to lose support for older watches. My understanding is that Swift now has conditional imports which will let you import a module only in the OS allows the import but the below code is not working? I'm still getting a compiling error "Compiling for watchOS 4.3, but module 'SwiftyStoreKit' has a minimum deployment target of watchOS 6.2:" and if I remove "import SwiftyStoreKit" the module isn't detected.

#if canImport(SwiftyStoreKit)
import SwiftyStoreKit

class SwiftyStoreKitWatchHelper {

}
#endif
1
I am looking for a solution for the same problem. Have you been able to import the framework without increasing the minimum deployment target to watchOS 6.2? - DeveloBär
@DeveloBär I never did resolve this so I bumped by minimum deployment target to WatchOS 6 once 7 came out. - GarySabo
Yeah, that‘s the best solution for now I guess. Thanks for replying! - DeveloBär

1 Answers

-1
votes

Try this

#if canImport(SwiftyStoreKit)
import SwiftyStoreKit
#endif

@available(watchOS 6.2)
class SwiftyStoreKitWatchHelper {
    
}