RORK LABJP
MAX — Rork Max builds native Swift apps rather than React Native, spanning iPhone, iPad, Apple Watch, Apple TV, Vision Pro, and iMessageAPIS — It reaches native Apple APIs including SwiftUI, ARKit, HealthKit, HomeKit, Core ML, and Metal, so AR/LiDAR scanning and on-device ML are in scopeCLOUD — Rork Max writes Swift, compiles it on cloud-hosted Macs, and streams a live simulator that accepts real touch inputSUBMIT — From there it prepares the build for device install or App Store submissionSEED — Rork raised a $15M seed led by Left Lane Capital in April, joined by Peak XV and a16z SpeedrunPRICE — It's free to start at roughly 5 prompts a week, paid plans begin at $25/month, and Rork Max runs $200/monthMAX — Rork Max builds native Swift apps rather than React Native, spanning iPhone, iPad, Apple Watch, Apple TV, Vision Pro, and iMessageAPIS — It reaches native Apple APIs including SwiftUI, ARKit, HealthKit, HomeKit, Core ML, and Metal, so AR/LiDAR scanning and on-device ML are in scopeCLOUD — Rork Max writes Swift, compiles it on cloud-hosted Macs, and streams a live simulator that accepts real touch inputSUBMIT — From there it prepares the build for device install or App Store submissionSEED — Rork raised a $15M seed led by Left Lane Capital in April, joined by Peak XV and a16z SpeedrunPRICE — It's free to start at roughly 5 prompts a week, paid plans begin at $25/month, and Rork Max runs $200/month
Articles/Dev Tools
Dev Tools/2026-07-16Advanced

Test Generated Purchase Code Before You Touch Sandbox — Automating Refunds, Expiration, and Failures with SKTestSession

Rork Max generates StoreKit 2 code that proves people can buy. It does not prove refunds, expiration, or failed purchases are handled. Here is how to cover those paths with SKTestSession before you ever open Sandbox.

StoreKit 216StoreKitTestSKTestSessionRork Max225Testing3In-App Purchase7

Premium Article

The first thing I noticed in the purchase code Rork Max produced was a fifteen-line function that walked Transaction.currentEntitlements and returned a Bool. Nothing about it was wrong. Buy the product, the feature unlocks.

The problem was everything downstream. What happens on a refund? What happens when renewal fails? Create a Sandbox account, buy, wait a month — that is not a workflow.

Billing bugs are frightening for an indie developer because they do not announce themselves. Paying customers see nothing wrong. What is broken is the entitlement of the handful of people who got refunded, and those people leave without saying a word.

StoreKitTest is Apple's answer to that blind spot. It stands up a fake App Store inside your test process, and lets you trigger refunds and expiration with your own hands.

Some Bugs Die Before Sandbox

Billing verification tends to start at Sandbox, but Sandbox answers a different question: can my app talk to Apple's servers correctly? It does not answer whether my own code reacts correctly to a change in state.

Conflating the two makes the process far too heavy for what you want to learn. Testing one refund means creating a Sandbox account, purchasing, issuing a refund from App Store Connect, and waiting for the notification. Tens of minutes per scenario — and when it fails, you cannot tell whether your code or the environment is at fault.

StoreKitTest owns the second question. No network, no servers. Everything stays inside the test process.

I draw the line like this:

What you want to verifyWhereCost per run
Refund removes entitlementSKTestSessionMilliseconds
Expiration removes entitlementSKTestSessionMilliseconds
Failed purchases are surfacedSKTestSessionMilliseconds
Signature verification on your serverSandboxMinutes
Server notifications arrive and processSandboxMinutes and up
Real charges and localized pricingSandbox / ProductionMinutes and up

The top three are technically possible in Sandbox, but there is little reason to spend the time there. The bottom three are impossible in SKTestSession. That is where the line belongs.

StoreKitTest Stands Up a Fake App Store On-Device

You need a .storekit configuration file and import StoreKitTest in your test target. You can build the configuration by hand in Xcode, but for a Rork Max project it is faster to sync it from your App Store Connect product definitions.

The moment you create an SKTestSession, every StoreKit 2 API in that process points at it. Product.products(for:) and Transaction.currentEntitlements are answered by the session, not by Apple.

import XCTest
import StoreKit
import StoreKitTest
@testable import MyApp
 
final class EntitlementTests: XCTestCase {
    var session: SKTestSession!
 
    override func setUpWithError() throws {
        try super.setUpWithError()
        // Products.storekit must be a member of the test target
        session = try SKTestSession(configurationFileNamed: "Products")
 
        // No confirmation dialogs. Otherwise the test waits for a human finger.
        session.disableDialogs = true
 
        // Do not carry transactions across tests
        session.clearTransactions()
        session.resetToDefaultState()
    }
 
    override func tearDownWithError() throws {
        session = nil
        try super.tearDownWithError()
    }
}

disableDialogs and clearTransactions() are the two lines that will hurt you if you skip them. Drop the first and your test hangs on a dialog forever. Drop the second and a subscription bought in an earlier test leaks into the next one, producing a pass you cannot explain. When a test passes "somehow," this is usually why.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
If you have verified that purchases work but never tested refunds or expiration, you can walk away today with working XCTest cases that reproduce both in milliseconds
You will learn how timeRate, expireSubscription, refundTransaction, and setSimulatedError collapse a month-long Sandbox renewal scenario into a single test
You can close the refund gap that generated code almost always leaves open, and verify billing logic before paying the $99 Apple Developer Program fee
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Dev Tools2026-07-13
Losing HealthKit Data on Incremental Sync — Designing HKQueryAnchor Persistence
When step or sleep data double-counts or goes missing on incremental HealthKit sync, the root cause is usually HKQueryAnchor persistence. Here is a working Swift design that handles newAnchor and deletedObjects correctly and stays consistent across reinstalls and background updates.
Dev Tools2026-07-12
A symbolEffect Field Memo: Making Icons Move Nicely in Your Rork Max App
Animate SF Symbols in a Swift app generated by Rork Max using bounce, pulse, variableColor, and contentTransition, with working code, OS-version gating, and the mistakes I made from over-animating.
Dev Tools2026-07-11
Implementing App Clips with Rork Max — delivering the core of your app the moment someone scans a code
Building on the native Swift that Rork Max produces, this note walks through the 15 MB App Clip budget, receiving the launch URL, and handing state off to the full app.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →