gradient blur

Testing Subscriptions and In-App Purchases for iOS Apps Before Launch

Want to easily test subscriptions, parental approval states and more before you launch? Here's how using Xcode's Transaction Manager.

codetest

Jordan Morgan

Developer Advocate

Published

Testing out purchases and subscription logic is a critical step to developing any iOS app. Today, I wanted to walk you through a few tips on how to make sure subscriptions are working properly before you launch. Beyond performing a purchase, there are several other edge cases to consider on iOS:

  • How does your app behave if the network conditions are poor?

  • What if the purchase requires parental approval?

  • How do you inspect transactions once they complete?

Apple has thought of all of these scenarios, and they offer two indispensable tools every developer should know about:

  1. StoreKit Configuration Files: This is a file which represents products that you'll offer in your app. The great thing about using one is that they can be completely detached from Apple's servers, meaning you can create ad-hoc products. Or, you can use it to represent the products you've made in App Store Connect one to one.

  2. Transaction Manager: Xcode's built-in tool to test, manage or otherwise mimic any purchasing state is called the Transaction Manager. Here, you can see transactions, remove them, put them in different states and more.

With those two things, you'll have all you need to test any purchase-related logic. These tools give developers access to representations of real products (using the StoreKit file) and a way to view a running history of them, remove them and more (using Transaction Manager). For the rest of the post, you'll see concrete examples of how to use these two tools together. But, if you're new to iOS - I'd suggest starting here first:

First, write your subscription or purchasing logic

Whether you're using StoreKit 2, Superwall or something else — you'll need your logic in place to purchase a product. The "how" is not the focus of this post, testing what's been purchased is. To set the context here, though, I'll be using our demo app, Caffeine Pal. It uses StoreKit 2 (which I wrote an extensive tutorial about over here). Here's the critical component to making a purchase:

// MARK: Private Functions

private func purchaseProduct(_ product: Product) async throws -> Bool {
    do {
        let result = try await product.purchase()

        switch result {
        case .success(let result):
            let verificationResult = try self.verifyPurchase(result)
            try await updateUserPurchases()
            await verificationResult.finish()

            return true
        case .userCancelled:
            print("Cancelled")
        case .pending:
            print("Needs approval")
        @unknown default:
            fatalError()
        }

        return false
    } catch {
        throw error
    }
}

swift

ungroup Copy

StoreKit configuration setup

Next, you need to create a StoreKit configuration file: Xcode -> File -> New from Template -> StoreKit Configuration File -> Next and then name it:

gradient blur
dashboard-header

Creating a StoreKit Configuration file

At this point, you can check the box to have it sync with the products you've already added in App Store Connect, or leave it unchecked if you'll be adding in your own manually. You can also have more than one configuration file, though only one can be active at a time. For Caffeine Pal, I added all of the products found in PurchaseOperations.swift. If you wanted to add your own, you could click the + down here (if you synced with App Store Connect, it'll look like a refresh circle instead):

gradient blur
dashboard-header

A StoreKit configuration file with products to test

Associating to a scheme

Now, you'll want to make the file active by associating it to a scheme. You have two options here:

  1. Create a new scheme: You can have a scheme in Xcode that's created solely for testing purchases.

  2. Use an existing scheme: Or, use an existing scheme and attach the file to it.

For my own projects, I go with option one — but it's a personal preference. Either way, you'll need to click on the scheme -> Edit Scheme -> Run -> Options -> StoreKit Configuration -> Choose your file:

gradient blur
dashboard-header

Attaching a StoreKit file to your scheme

Also, if you're testing on an actual device, you'll need to activate Developer Mode now. You can do that within the Settings app. If you're using the simulator, there's no additional steps required.

Perform a purchase

At this point, you're all set to ensure a purchase goes through. In Caffeine Pal, we'll make sure that a few core flows work as intended:

  1. Tapping on a "pro" feature should show a paywall. This confirms we're checking subscription state for inactive users.

  2. The paywall shows with the products required. This confirms our products are loading.

  3. The purchase itself is carried out. This, obviously, confirms users can convert.

  4. Finally, we have app-specific logic to show a "Welcome" view once a subscription starts. If a user converts, we need to confirm that shows post-purchase.

With the StoreKit configuration file activated with the scheme, you should be able to follow that same flow successfully if you've pulled down the project from Github:

gradient blur
dashboard-header

Starting from the left, the end-to-end purchase flow can now be tested

The takeaway here is that with a StoreKit configuration file, you can easily test any product you can think of — without dealing with the logistical hurdles that creating a product in App Store Connect can present. The fact that it can work with your "real" products, or any you create on the fly, make it a critical tool for developing apps on Apple's platforms.

Viewing, editing and removing transactions

Finally, we arrive at the Transaction Manager. Before it came around, dealing with "resetting" state, testing parental approval flows and anything else with subscriptions or purchases was a bit of a chore. Now, it's a click of a button.

Since a conversion occurred in the previous step, it'll be viewable (and editable) in the Transaction Manager: Xcode -> Debug -> StoreKit -> Manage Transactions:

gradient blur
dashboard-header

Xcode's Transaction Manager

Make sure you select your app from the left-hand sidebar. Clicking on a specific transaction is where things get interesting. You can cancel the subscription, delete it altogether (i.e. resetting state, the most common use), request a price increase, refund it and more. Here, right click the transaction to bring up the context menu, and choose "Delete Transaction" and run the app again. You'll see that we no longer have access to pro features, and we can test the flow over again.

Keep in mind that this works for any transaction. So, if you have a credits-based system with consumable purchases, those work all the same. It's an incredibly flexible tool that can mimic any subscription or purchasing state possible on iOS.

For example, beyond the subscription tier in Caffeine Pal, there are also individual in-app purchases for espresso recipes available. Purchasing one shows up the exact same way that a subscription conversion does:

gradient blur
dashboard-header

A consumable in-app purchase showing in the Transaction Manager

This means testing scenarios such as confirming that a subscription unlocks all recipes, or that without one — recipes are purchasing correctly, are all done within minutes.

Wrapping up

With StoreKit configuration files and Transaction Manager, it's never been easier to test subscription flows. What used to require a myriad of steps is now set up and done in a few minutes. If you're pre-launch (or testing new things even if you have launched), this is the quickest way to start testing purchasing flows. Once things look good, then you shuttle your app off to TestFlight or the App Store.

Other resources

If you want to dig in more, here are some great resources to check out:

  1. Our YouTube video over the Transaction Manager.

  2. Our docs page over setting these flows up (same information, but more succint).

  3. Apple's article over StoreKit configuration files.

  4. Apple's article over Transaction Manager.

As always, if you want access to the best paywall testing suite, revenue charts or web checkout tools — get started with a free Superwall account today.

Stay up to date

Subscribe to our newsletter and be the first to know about new features, updates, and more.

gradient blur

Get a demo

We'd love to show you Superwall

Want to learn more?

  1. Fill out this tiny form →
  2. We'll prepare you a custom demo
  3. Walk you through Superwall
  4. Follow up and answer questions

Key features

  • Drag 'n Drop Paywalls
  • 200+ Custom Templates
  • Unlimited A/B tests
  • Surveys, Charts & More

Select one...

Select one...

By proceeding you consent to receiving emails and our terms.

gradient blur
shape-starshape-starshape-starshape-starshape-star

Customer Stories

Our customers refer to Superwall as their most impactful monetization tool. In their own words:

dashboard-header

Thanks to Superwall, we were able to 2x our iOS app profitability in just six months. It has greatly assisted our growth team in achieving exceptional results by facilitating high-frequency experimentation.

Mojo launch
Bernard Bontemps, Head of Growth
dashboard-header

Really excited about the progress we made recently on paywalls with Superwall. We got more than 50% increase in conversion for upsell screens. This is crazy.

Photoroom launch
Matthieu Rouif, CEO
dashboard-header

Superwall has completely changed the game for us. We’re able to run experiments 10x faster and unlock the ideal monetization model for our users.

RapChat launch
Seth Miller, CEO
dashboard-header

Superwall made testing paywalls so much faster. Instead of releasing a new version of the app each time, we were able to iterate on the winning paywalls much quicker. Thanks to that it increased our revenue per customer by 40%.

Teleprompter launch
Mate Kovacs, Indie Dev
dashboard-header

Superwall lets us move 10x faster on our monetization strategy. We can build and launch multiple paywall iterations without the need for client releases or complicated deploys. Our product iteration loop is days, rather than months because of Superwall.

Citizen launch
Jon Rhome, Head of Product
dashboard-header

Superwall enables Bickster’s marketing team to design and optimize app paywalls, freeing up engineering to concentrate on innovation. As a result, Superwall helped accelerate our install-to-subscription rates, lower engineering expenses, and cured our team’s frustration with the (once) time-consuming process of iterating on paywalls.

Bickster launch
Chris Bick, CEO
dashboard-header

Superwall has revolutionized our monetization strategy. It’s an essential tool that allows rapid paywall testing and optimization, leading to remarkable improvements in our subscription conversions and revenue generation. Can’t recommend Superwall enough for any app-based business.

Coinstats launch
Vahe Baghdasaryan, Sr. Growth
dashboard-header

Superwall has played an integral part of improving our subscription business. Compared to other providers, Superwall has proven superior in facilitating high-frequency experimentation allowing us to achieve an ideal monetization model, resulting in a significant increase in revenue.

Hornet launch
Nils Breitmar, Head of Growth
dashboard-header

Superwall is the single greatest tool we’ve used to help us increase our revenue. Our material wins from Superwall are greater than any tool we’ve worked with to date!

Pixite launch
Jordan Gaphni, Head of Growth
dashboard-header

Shout out to Superwall for helping us dial in our paywall — made a big impact on monetization, increasing revenue by more than 50% 💸

Polycam launch
Chris Heinrich, CEO
dashboard-header

Superwall increases revenue. Full stop. Being able to test paywalls on the fly and quickly analyze results has drastically increased our revenue and improved our monetization of users. Highly recommend this tool!

Hashtag Expert launch
Zach Shakked, Founder
Start for FREE

Simple win-win pricing

Interest aligned pricing. Contact us for a discount.

dashboard-header
Indie
Free
Up to 250 conversions per month
Access to every standard feature
Try it free

Standard Features

  • 250 Conversions a Month
  • Drag 'n Drop Paywall Editor
  • 200+ Paywall Templates
  • Unlimited A/B tests
  • Charts & Analytics
dashboard-header
Startup
$0.20/conversion
Pay as you go pricing that scales
Up to 5,000 conversions a month
Sign Up

Standard Features

  • 5,000 Conversions a Month
  • Drag 'n Drop Paywall Editor
  • 200+ Paywall Templates
  • Unlimited A/B tests
  • Charts & Analytics
dashboard-header
Growth
Flat-Rate
100% custom flat-rate pricing
Terms that make sense for you
Get Pricing

Premium Features

  • Unlimited Conversions
  • We Build Your Paywalls
  • 4 Weekly Growth Meetings
  • Dedicated Slack Channel
  • Custom Integrations