StoreKit Testing in Xcode 12 and iOS 14 In-App Purchases Simulator

Mobile in-app subscriptions are the most popular monetization method for most non-gaming apps these days. Yet implementing and testing in-app subscriptions in iOS is a complicated task.

Luckily Apple has presented a set of new convenient features for StoreKit testing in their Introducing StoreKit Testing in Xcode session during WWDC 2020. We have summarized the key changes for you.

What’s new

  1. StoreKit Configuration File –  allows you to set up the in-app products for testing directly in Xcode 12. No need to create them in App Store Connect anymore. 
  2. StoreKit Transaction Manager – transaction manager allows you to see all in-app purchases locally and manage their statuses;
  3. StoreKitTest Framework – a new framework for running tests in Xcode that provides full control over them;
  4. Sandbox subscription management on devices.

StoreKit Configuration File

StoreKit Configuration File allows you to set up a local environment for in-app purchases testing without creating in-app products in App Store Connect.

To create StoreKit Configuration file just go File → New → File

Create StoreKie Configuration File
New StoreKit Configuration File

You can use three product types:

  • Consumable In-App Purchase 
  • Non-Consumable In-App Purchase 
  • Auto-Renewable Subscription

Now it is possible to change the rate at which time passes for auto-renewable subscriptions in a test environment using the Time Rate configuration:

StoreKit Transaction Manager

StoreKit Transaction Manager is a very useful tool for local development and in-app subscription testing.

StoreKit Transaction Manager allows to:

  • cancel a subscription
  • refund a subscription
  • reset a subscription (as if a purchase never happened)
  • set a billing retry state for a subscription

To access the StoreKit Transaction Manager you need to choose your StoreKit Configuration File and click on the icon in the debugging area(field/bar).

StoreKitTest Framework

StoreKitTest Framework

New StoreKitTest framework works together with StoreKit Configuration File and allows creating Unit and UI tests. It allows testing automation for in-app purchases. The state is managed by SKTestSession. You can test:

  • Successful purchases
  • Failed purchases
  • Interrupted purchases
  • External transactions
  • Subscription offers

Managing Sandbox subscriptions

Sandbox subscription can be canceled or changed to another subscription within the same subscription group on a device.

There is also a new Reset Eligibility setting that resets the introductory offer. You no longer need to create a new sandbox account for testing.

Managing Sandbox subscriptions with StoreKit

Conclusions

New features provide developers with a flexible environment and in-app transaction management tools. New capabilities of in-app test automation will help ship faster to the App Store and implement a more reliable in-app subscription.

To the best of my knowledge, it is the most significant update of testing capabilities for in-app purchases on iOS. I am sure it will improve the developer experience with in-apps and reduce the problems of in-app product implementation.

To learn more on how to handle StoreKit Errors please read this guide or discussions.