Get started with StoreKit Testing in Xcode
Learn how to test in-app purchases locally.
04 Sep 2023 · 4 min read
With StoreKit Testing in Xcode, Apple introduced the possibility to simulate and test in-app purchases and subscriptions in a controlled environment. By using StoreKit Testing, we can now test in-app purchases locally in Xcode without needing to connect to App Store Connect.
In this article, we'll look at how this approach works.
Let's dive in.

Overview
To setup StoreKit testing in Xcode, the following steps are required:
- Creating and configuring a StoreKit configuration file.
- Enabling StoreKit testing in Xcode.
- Test purchasing products.
Let's look at each step in more detail.
1. Creating a StoreKit configuration file
A StoreKit configuration file contains the in-app purchase options and their configurations. To create a StoreKit configuration file, Xcode provides a template:

There are two types of StoreKit configuration files:
- local - which we can use if we didn't set up the iOS application in App Store Connect or in case we want to try out new types of in-app purchases or subscriptions before setting them up in App Store Connect
- synced - which we can use if we already did setup in-app purchases in App Store Connect and would like to test them in Xcode.
Let's look at how to use both types of configuration files.
1.1 Configuring a local StoreKit configuration file
After creating a StoreKit configuration file, we can start configuring in-app purchase options the iOS application will provide.

As shown above, we can use the + button to configure different types of in-app purchases, set their product ids etc.
1.2 Configuring a synced StoreKit configuration file
To use a synced file, the creation dialog provides a sync option where we can configure which team and app to use with App Store Connect.

We cannot edit a synced configuration file unless we convert it to a local one.
2. Enabling StoreKit testing in Xcode
By default, StoreKit testing in Xcode is disabled. We can activate it by selecting the configuration file in the scheme editor:

To disable StoreKit testing, we can restore the default state by selecting none.
Test purchasing products
With a finished StoreKit testing setup, we can start testing our in-app purchasing code by purchasing products through our app. Every purchase will be simulated by Xcode.
After purchasing a product, we can use Xcode to manage transactions, for example to reset the purchase for testing purposes or to test a refund or a price increase.

We can open the transaction manager from the bottom buttons bar when the configuration file is open or from Xcode's menu Debug -> StoreKit -> Manage transactions.

Newsletter
Like to support my work?
Say hi
Related tags
Articles with related topics
Latest articles and tips