StoreKit testing in the Simulator allows you to speed up testing in-app purchases for your app. You can test in-app purchases in Xcode by generating a StoreKit configuration file containing the available products for your app. You’ll be able to purchase products without connecting to App Store servers, without an internet connection, and you’ll be able to test edge cases like failing transactions.
A cumbersome process of using StoreKit configuration files has been to ensure using up-to-date products for your app. I’ve been testing Stock Analyzer for a while with introduction offerings that no longer existed, potentially trying use cases in the app that won’t happen in production. It’s essential to keep your configuration files up to date, and I’ll explain how you can do so using a new feature in Xcode 14.
Sync In-App Purchase products from App Store Connect into a StoreKit Configuration file
By syncing a StoreKit configuration file with App Store Connect, you’ll allow Xcode to fetch In-App Purchase data automatically. You’re no longer required to manually ensure filling in the correct data or copy the bundle identifier for each product your app offers. You’ll significantly benefit from this feature if your app contains many different products.
You can generate a StoreKit Configuration file by adding a new file in Xcode:
After tapping the next button, you’ll see a new checkbox allowing you to sync the configuration file with App Store Connect:
Xcode will fetch a list of available apps using the configured teams and should select the correct application by default based on the bundle identifier your project uses, but it’s worth verifying manually. The products will be fetched from App Store connect once you’ve finished creating the configuration file:
You can start StoreKit testing by selecting the newly generated configuration file from the scheme settings:
StoreKit testing using the newly generated configuration file ensures that you’re testing the latest version of your In-App Purchases. You can update your configuration file whenever you make changes to the products offering, ensuring your testing configuration stays up-to-date.
How can I manually sync In-App Purchase updates?
Xcode might automatically sync the latest changes from App Store Connect. Still, verifying yourself or even manually refreshing your configuration file once you’ve made changes to your app’s offering is good. You can manually refresh by tapping the refresh button at the bottom left in the StoreKit Configuration file:
How can I enable syncing for an existing StoreKit Configuration file?
Unfortunately, it’s not possible to enable syncing for an existing StoreKit Configuration file. Instead, you’ll have to generate a new file for StoreKit Testing. If needed, you can decide to keep your old configuration files for specific testing scenarios supported by these files.
StoreKit Testing becomes more accessible using a StoreKit Configuration file that Xcode syncs with App Store Connect. By ensuring your local environment represents the latest In-App Purchase configurations, you’ll be testing the app closer to the production environment. You need to replace an existing configuration file with a new one to benefit from syncing.
If you want to improve your Xcode knowledge, even more, check out the Xcode category page. Feel free to contact me or tweet me on Twitter if you have any additional tips or feedback.