How to code and test StoreKit purchases in Swift and XCode

Oscar de la Hera Gomez
Three flowers that represent StoreKit, Swift and XCode side by side. Beneath them sits the text “Code & Test StoreKit Product Purchases.”

A step by step guide on implementing and testing StoreKit product purchases for In-App Purchases and Subscriptions.

The guide was made using our Free iOS StoreKit 2 Open Source project which is recommended for developers or business folk wishing to learn about how In-App Purchases or Subscriptions work and the code behind them.

The following walkthrough assumes that you have already setup StoreKit with an offering and developed a UI that allows an app to display products.

Please consult the guides below to learn how to setup StoreKit, create a StoreKit offering or design a UI that considers all StoreKit scenarios.

Step One: Implement the StoreKit Coordinator

A screenshot of XCode showing the StoreKit Coordinator files. All the code for the files is available below.

Follow our guide below to implement a singleton that handles all the base StoreKit transactions, including purchases.

Step Two: Code the product purchase

A screenshot of Xcode showing the code that's required to make a purchase. The snippet is available below.

In Swift, on the button that allows you to purchase a product, implement the code below.

If you are curious about why we use DebuggingIdentifiers or how Async Await works, please consult the articles below.

Step Three: Verify

A screenshot of an iOS app showing a completed purchase.

Run the app and make a purchase.

If your apps UI does not update to show that the product has been successfully purchased, open the StoreKit Transaction Manager to confirm that the purchase was made and that the transaction was added to the customers transaction history.

A screenshot of the Xcode StoreKit Transaction Manager showing the confirmed purchase.

Looking to learn more about developing apps with StoreKit 2?

Read our comprehensive development guide linked below to learn about all the secrets behind developing In-App Purchases and Subscriptions with StoreKit 2.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details