> For the complete documentation index, see [llms.txt](https://docs.onside.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.onside.io/sdk/advanced-and-tooling/testing-installation-and-purchases.md).

# Testing Installation & Purchases

Testing an OnsideKit integration during development comes down to two independent pieces, and neither one needs a production backend or a live install:

1. **The purchase flow** — fetching products, buying, and restoring.
2. **The install source** — how your app reports the marketplace it was installed from, when you distribute through an alternative app marketplace.

This page shows how to simulate both in Xcode so you can exercise your integration end to end before going live.

## 1. Testing the purchase flow

OnsideKit can run fully offline against a bundled **`.storekit`** configuration file. Products, login, purchases, and restores are all simulated locally — no backend, no registered app, and no real Onside account. This is the recommended way to develop and QA the purchase UI.

Pass the `.storekit` file's base name to `initialize`:

```swift
Onside.initialize(storeKitConfigurationName: "LocalProducts")
```

The standard OnsideKit APIs are unchanged — the same payment queue, observers, and transaction flow — so what you test here matches what ships.

{% hint style="info" %}
Local testing is documented in full — setup, behavior, the supported `.storekit` fields, the APIs that aren't available offline, and resetting state between runs — in [**Local Testing with a .storekit File**](/sdk/advanced-and-tooling/local-testing.md).
{% endhint %}

## 2. Testing the install source

When you distribute your app through an alternative app marketplace, your app — and some Apple frameworks — can branch on **how the app was installed**. MarketplaceKit exposes this through [`AppDistributor`](https://developer.apple.com/documentation/marketplacekit/appdistributor) (iOS 17.4+):

```swift
import MarketplaceKit

switch AppDistributor.current {
case .appStore:                  break
case .testFlight:                break
case .marketplace(let bundleID): break // installed from an alternative marketplace
case .web:                       break
case .other:                     break
@unknown default:                break
}
```

`AppDistributor.current` reports the source the app installed from:

| `AppDistributor.current` | Install source                                                            |
| ------------------------ | ------------------------------------------------------------------------- |
| `appStore`               | The App Store.                                                            |
| `testFlight`             | TestFlight.                                                               |
| `marketplace(_:)`        | An alternative app marketplace; the associated `String` is its bundle ID. |
| `web`                    | The developer's website.                                                  |
| `other`                  | Enterprise or education developer programs.                               |

{% hint style="info" %}
This is a property of **your app**, not of OnsideKit. OnsideKit's product, purchase, and restore APIs behave identically regardless of `AppDistributor.current`. The technique below is for testing the code in your app that reacts to the install source.
{% endhint %}

### Simulate a marketplace install during development

Your app can install from an alternative marketplace only after it passes **Notarization**, so before that you can't get a real marketplace install on device. To test any code that branches on `AppDistributor.current` beforehand, override the install source for development builds.

{% hint style="info" %}
This section summarizes Apple's [Distributing your app on an alternative marketplace → Test your app during development](https://developer.apple.com/documentation/marketplacekit/distributing-your-app-on-an-alternative-marketplace#Test-your-app-during-development). Refer to Apple's documentation for the authoritative, up-to-date steps.
{% endhint %}

**1. Declare the marketplaces in your build settings.**

Set your target's **Alternative Distribution - Marketplaces** build setting — identifier `MARKETPLACES` — to the list of marketplace bundle IDs your app can install from. The **Onside marketplace** bundle ID is `com.onside.marketplace-app`. Open the project in **Xcode 15.3 or later** and add the build setting manually if one by that title isn't already present.

```
MARKETPLACES = com.onside.marketplace-app
```

This build setting overrides `AppDistributor.current` for development builds, so you can test any custom branching — a different image, different menu items, and so on — without a notarized build.

**2. Choose the marketplace in your run scheme.**

In **Product → Scheme → Edit Scheme… → Run → Options** tab, use the **Distribution** menu to pick that marketplace's bundle ID. Runs on device through Xcode then simulate an install from that marketplace.

With `com.onside.marketplace-app` selected, `AppDistributor.current` returns:

```swift
.marketplace("com.onside.marketplace-app")
```

**3. Override it in a test plan (optional).**

To exercise the same branching from automated tests, choose a marketplace bundle ID in the **Distribution** menu of your **test plan's configuration**. This overrides the distributor for that test plan.

{% hint style="warning" %}
These settings only affect development builds. They simulate the install source so you can test locally — they don't change how a released build is distributed, and a production install reports its real source.
{% endhint %}

## See also

* [Local Testing with a .storekit File](/sdk/advanced-and-tooling/local-testing.md) — the full reference for offline purchase testing.
* [OnsideKit vs OnsideKitLite](/sdk/advanced-and-tooling/onsidekit-lite.md) — the two SDK builds, and which one to test against.
* [Debugging & installationId](/sdk/advanced-and-tooling/debugging.md) — logs and identifiers for diagnosing an integration.
* Apple — [`AppDistributor`](https://developer.apple.com/documentation/marketplacekit/appdistributor) and [Distributing your app on an alternative marketplace](https://developer.apple.com/documentation/marketplacekit/distributing-your-app-on-an-alternative-marketplace).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.onside.io/sdk/advanced-and-tooling/testing-installation-and-purchases.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
