I am testing an in-app purchase in my app. The app has a multiplatform target with Mac (native, not Catalyst) and iPad destinations. I created a local StoreKit configuration file in Xcode and added an IAP to it. I edited the Xcode scheme to use my local config file. I have the following code to fetch the IAP:
@Published private(set) var products: [Product]
@MainActor
func fetchProducts() async {
let productIdentifiers = ["com.pro_version"]
do {
products = try await Product.products(for: productIdentifiers)
} catch {
print("Failed product request from the App Store server: \(error)")
}
}
When I call this function, the products
array is always empty on Mac but is not empty on iOS.
I checked that the product ID for the product in the config file matches the value of the productIdentifiers
constant in the code.
What am I missing that is preventing me from fetching the products from my local StoreKit config file on Mac?
What am I missing that is preventing me from fetching the products from my local StoreKit config file on Mac?
I was missing a Mac build in TestFlight. Once I added a mac build in TestFlight and got the build approved for external testing, I was able to fetch the products on Mac.