For the complete documentation index, see llms.txt. This page is also available as Markdown.

Testing Installation & Purchases

Test an OnsideKit integration during development before your app is notarized and live: simulate the purchase flow with a local StoreKit file, and simulate the alternative-marketplace install source i

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:

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.

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.

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 (iOS 17.4+):

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.

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.

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.

This section summarizes Apple's Distributing your app on an alternative marketplace → Test your app during development. Refer to Apple's documentation for the authoritative, up-to-date steps.

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.

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:

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.

See also

Last updated

Was this helpful?