ios17visionosstorekit2

Ios16 and ios17 purchases in same code base posible?


Has anybody been able to make storekit purchase to work for an ios16 purchase and an ios17 purchase in the same code base?

I have an ios/ipad/mac code base that I am reusing for visionOS, everything works except the storekit in ios17 uses @Environment.purchase) to make purchases, but ios16 build doesn’t recognize that. Has anybody implemented ios16 and ios17 purchases in the same code base?


Solution

  • This seems like the use case that #available is meant to solve.

    if #available(iOS 17, *) {
        print("This code only runs on iOS 17 and up")
    } else {
        print("This code only runs on iOS 16 and lower")
    }