StoreKit Testing Improvements in iOS 14
A TLDR of the new StoreKit testing features announced at WWDC 2020
Jacob Eiting
Configuring and testing in-app purchases is one of the most annoying, but most critical steps of building iOS apps. Apple just made the process a whole lot easier with killer new tools and features announced at WWDC 2020!
Watch the full session video here: Introducing StoreKit Testing in Xcode
TLDR
- You can set up your StoreKit products for testing in Xcode before having to add them to App Store Connect!
- StoreKitTest.framework works with XCTest enabling unit & UI tests of in-app purchases running in Xcode’s new Local StoreKit environment.
- StoreKit Transaction Manager in the Local environment allows control of refunds, cancellations, permission to buy, interrupted/failed purchases, and other important scenarios for testing.
- Time Rate adjusts the speed of renewals to enable faster testing cycles.
- New subscription management options for the developer sandbox environment allows more thorough on-device testing.
- You can now use StoreKit Config files with RevenueCat to test. Check out our docs to learn more.
What’s New?
StoreKit Configuration File
What is it?
- New file type in XCode (JSON encoded)
- Allows developers to configure SKProducts from Xcode for testing.
- Developers set the StoreKit file up with product IDs, subscription groups, introduction offers, etc. It’s what you’d usually configure in the In-App Purchases section in App Store Connect.
- It’s tied to a Scheme, and is enabled by going into Edit Scheme, and then under Run, selecting a StoreKit Configuration.
What does it mean?
- You’ll be able to test how products will look and perform before they’re configured in App Store Connect, or before they’re propagated.
- You’ll be able to test many features that only worked in production before, like subscription cross-grades, interruptions, and more.
- This file will also be used for automated tests.
Important Note:
- Receipts generated using the local StoreKit configuration file will be signed with a different, app-specific certificate. This certificate is exportable from the StoreKit configuration editor menu, and you’ll have to use it in order to verify it (or use RevenueCat we’ll provide developers the ability to upload their certificates and use them for receipt validation soon).
Purchases in the simulator
What is it?
- The iOS Simulator can now be used to test purchases in the Local StoreKit environment.
What does it mean?
- You can test in-app purchases without a device.
- You can now write automated tests that make purchases.
- The StoreKit Configuration file must be selected in the scheme in order for purchases to work in the Simulator.
- The prompt is very similar to the one used for production, with the nice UI that displays all of the details of the product. This happens for physical devices as well.
StoreKitTest Framework
What is it?
- It’s a new framework, meant to be used in automated tests, that will allow for full programmatic control of the StoreKit Local environment.
- It also uses the same StoreKit configuration files.
- It can make purchases with no user interaction required.
What does it mean?
- The new framework can be used to create very complete integration tests. You can use it to simulate purchases that succeed, fail, get interrupted, external transactions and subscription offers.
New Sandbox Controls on Device
What is it?
- There’s a new option in the Sandbox Account section of iOS settings, called “Manage”.
- The option takes you to a section where you can enable / disable renewal receipts, as well as see active subscriptions for the sandbox account.
- By going into the active subscriptions, you get a screen that’s similar to iOS’s Manage Subscription page, and allows you to change into a different subscription.
- There’s a Sandbox-only button called “Reset Eligibility”, which allows you to reset the introductory offer eligibility for the sandbox user. No more creating a new sandbox account every time you want to test an introductory offer!!!
Other Xcode Tools for Local Testing
- Speed up purchases: you can now select the Sandbox duration of subscriptions.
- Manage transactions from Xcode: you can now see all of the transactions made by a user within Xcode, and you can use that interface to perform cross-grades, cancellations, refunds, and simulate interrupted purchases (interrupted purchases are the ones that happen when there’s an issue with payment, for example).
These new tools and features will improve the quality of apps in the App Store – and quality of life for developers. Bravo Apple!
We’ve integrated these changes into our platform so you can use StoreKit Config files with RevenueCat to test. Check out our docs to learn more.
In-App Subscriptions Made Easy
See why thousands of the world's tops apps use RevenueCat to power in-app purchases, analyze subscription data, and grow revenue on iOS, Android, and the web.