Hello,
I'm trying to add in-app purchases to a macOS app but failing to load the local test products. From the docs and various examples I've found online, it should be pretty straightforward with StoreKit 2.
So far, I've done the following:
added in-app purchase capability
created the local .storekit file
added consumable and non-consumable products
updated the scheme to use the test StoreKit configuration
verified the products are present and can be purchase by using Debug > StoreKit > Manage Transactions to make direct purchases
verified the product IDs are correct
To simplify things I tried creating a barebones app. I created a new .storekit file and added a single non-consumable product with ID product1. I used the default view and just a task to retrieve the products:
import SwiftUI
import StoreKit
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.task {
let products = try? await Product.products(for: ["product1"])
print(products)
}
.padding()
}
}
The print statement output is: Optional([])
I know I must be doing something wrong, but I'm completely missing it. I hope someone can help me.
Thanks