Give your simulator superpowers

Give your Xcode
Simulator extra features

Faster StoreKit testing by syncing in-app purchase products

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:

StoreKit testing starts by adding a configuration file
StoreKit testing starts by adding a configuration file.

After tapping the next button, you’ll see a new checkbox allowing you to sync the configuration file with App Store Connect:

StoreKit Testing becomes easier by syncing products with App Store Connect.
StoreKit Testing becomes easier by syncing products 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:

A StoreKit Configuration file with App Store Connect syncing enabled.
A StoreKit Configuration file with App Store Connect syncing enabled.

You can start StoreKit testing by selecting the newly generated configuration file from the scheme settings:

Start StoreKit Testing by selecting your newly generated configuration file.
Start StoreKit Testing by selecting your newly generated configuration file.

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:

StoreKit Testing with up-to-date products might require a refresh.
StoreKit Testing with up-to-date products might require a refresh.

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.

Conclusion

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.

Thanks!

 

Featured SwiftLee Jobs

Loading RSS Feed

Browse more Swift related Jobs, or add your own on SwiftLee Jobs