> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.qonversion.io/llms.txt
> Use this file to discover all available pages before exploring further.

# StoreKit testing in Xcode

> Set up and test in-app purchases with a StoreKit Configuration file in Xcode together with Qonversion: create the file, export its public certificate, upload it to the Dashboard, run test purchases, and clear the test data afterwards.

StoreKit Configuration files in Xcode let you test in-app purchases locally, without connecting to App Store servers. Upload the file's public certificate to Qonversion and your local test purchases flow through Qonversion just like real ones — entitlements, analytics, and webhooks all work.

<Note>
  Uploading a certificate does not affect real users. Production receipts signed by Apple keep validating through Apple; the certificate is only used to validate receipts produced by your StoreKit Configuration file.
</Note>

Official Apple guide: [Setting up StoreKit testing in Xcode](https://developer.apple.com/documentation/xcode/setting-up-storekit-testing-in-xcode/).

## 1. Create a StoreKit Configuration file

<Steps>
  <Step title="Add the file">
    In Xcode, go to **File → New → File from Template**, search for *StoreKit*, and choose **StoreKit Configuration File**. Save it.
  </Step>

  <Step title="Add your products">
    Inside the `.storekit` file, add the in-app products you want to test — consumables, non-consumables, and auto-renewable subscriptions.
  </Step>

  <Step title="Attach it to your scheme">
    Open **Product → Scheme → Edit Scheme… → Run → Options → StoreKit Configuration** and select your `.storekit` file.
  </Step>
</Steps>

## 2. Export the public certificate

Qonversion needs the public certificate from your StoreKit Configuration file to validate transactions.

<Steps>
  <Step title="Select the file">
    In Xcode's Project navigator, select the `.storekit` file.
  </Step>

  <Step title="Save the certificate">
    From the menu bar choose **Editor → Save Public Certificate** and save the `.cer` file locally.
  </Step>
</Steps>

## 3. Upload the certificate to Qonversion

<Steps>
  <Step title="Open Stores settings">
    In the Qonversion Dashboard go to **Project Settings → Stores**.
  </Step>

  <Step title="Add the certificate">
    In the **Apple App Store** card click **Add certificate**, then drop or select your `.cer` file in the panel that opens.
  </Step>
</Steps>

Once uploaded, the **StoreKit test certificate** chip turns green. To stop accepting StoreKit Configuration receipts, click **Remove** on that chip.

<Note>
  Only `.cer` and `.pem` public certificates are accepted — never upload a private key or an Apple production certificate.
</Note>

## 4. Run test purchases

Run your app in the Simulator or on a device using the scheme with your StoreKit Configuration file, and buy products as usual. Qonversion validates each transaction with your uploaded certificate, so local test purchases grant entitlements and appear in analytics just like real ones.

<Warning>
  If you set an **accelerated subscription renewal rate** in your StoreKit Configuration file, we strongly recommend **not** reusing the same test account. Accelerated renewals create a new transaction every few seconds, so that account piles up test data very quickly.

  Periodically **reinstall the app** to start fresh from a new `clientUid` and keep accounts from getting cluttered. For ordinary test cases (no accelerated renewals) this isn't needed — data won't accumulate.
</Warning>

## 5. Manage and clear test data

Purchases made through your StoreKit Configuration certificate are tagged **sandbox** and show up in your test-mode analytics next to Apple Sandbox purchases. They are **not** removed when you reset StoreKit in Xcode.

<Warning>
  Use a separate `clientUid` (user identifier) in your test build so StoreKit test data stays isolated from your real customers.
</Warning>

To clear StoreKit test data from Qonversion:

* **The whole project** — on the **Customers** page, open the ⚙ chart settings and choose **Reset StoreKit test data**.
* **A single customer** — open the customer and use **Reset StoreKit test data** next to the sandbox icon.

This removes only purchases made through the StoreKit Configuration certificate. Apple Sandbox, TestFlight, and real App Store purchases are never affected.
