/apple-dev-skills:storekit2-iap-defaultsfrom apple-dev-skills
Provides default StoreKit 2 architecture for a single non-consumable IAP (Remove Ads, Pro Unlock) including StoreKitBridge isolation, entitlement derivation, finish() timing, restore purchases, and test seam with .storekit.
Ships in apple-dev-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Default shape for the smallest IAP most solo/small apps ship: one
non-consumable unlock (Remove Ads, Pro Unlock). Product, Transaction, and
AppStore have no public initializers — you cannot construct a fixture — so
the seam below exists to make StoreKit 2 testable at all, not for abstraction's
sake.
Product.products(for:), Transaction.updates,
Transaction.currentEntitlements, or AppStore.sync().finish(), or how to
implement Restore Purchases..storekit configuration file or a StoreKit unit-test seam.Owns: bridge/seam shape, entitlement-derivation rules, test strategy for non-consumable IAP. Does NOT own:
currentEntitlements() shape is deliberately "own it or don't."monetization-sdk-integration.app-store-review-rejections.POST /v2/inAppPurchases plus inAppPurchaseLocalizations,
inAppPurchasePriceSchedules, and inAppPurchaseSubmissions for
automating this end-to-end → asc-api-automation; the web UI is the
manual alternative.local-archive-export-upload.Product/Transaction/AppStore are untestable globals. Put a protocol
between the client and StoreKit; tests inject a fake instead:
// StoreKitBridge.swift — no `import StoreKit`; fully fake-able.
protocol StoreKitBridge: Sendable {
func products(for ids: Set<String>) async throws -> [BridgeProduct]
func currentEntitlements() async -> Set<String>
func purchase(productId: String) async throws -> BridgePurchaseOutcome
func sync() async throws
func transactionUpdates() -> AsyncStream<BridgeTransactionEvent>
}
struct BridgeProduct: Sendable, Equatable { let id, displayName, displayPrice: String }
enum BridgePurchaseOutcome: Sendable, Equatable {
case success(productId: String), userCancelled, pending, failed(reason: String)
}
// LiveStoreKitBridge.swift — the ONLY file that imports StoreKit.
import StoreKit
struct LiveStoreKitBridge: StoreKitBridge {
func currentEntitlements() async -> Set<String> {
var ids: Set<String> = []
for await result in Transaction.currentEntitlements {
guard case .verified(let t) = result, t.revocationDate == nil else { continue }
ids.insert(t.productID)
}
return ids
}
// products(for:) / purchase(productId:) / sync() / transactionUpdates()
// follow the same shape: Product.products(for:), Product.purchase(options:)
// (visionOS: purchase(confirmIn:options:) instead — purchase(options:)
// isn't available there), AppStore.sync(), Transaction.updates.
}
Everything above LiveStoreKitBridge talks only to any StoreKitBridge — zero
import StoreKit. Verify: rg '^(internal |public )*import StoreKit' Sources/
→ expect exactly 1 hit.
finish(), restorecurrentEntitlements() each time (a
non-consumable with revocationDate == nil is entitled); an independently
stored boolean drifts from Apple's record on refund/family-share/restore.finish() after the entitlement is applied, not before (risks
losing the unlock on a mid-purchase crash) and not never (an unfinished
transaction is redelivered via Transaction.updates on every launch).Transaction.updates listener starts at app launch, not lazily on
first paywall visit — refunds/family-share revocations/Ask-to-Buy approvals
can arrive while the user is anywhere in the app.restorePurchases() always calls AppStore.sync() first, even when a
local cache looks empty — Apple's sync() docs position it as the forced
sync behind a user-initiated Restore Purchases control (Guideline 3.1.1
itself only asks for a restore mechanism), so it's not an optimization to
skip:func restorePurchases() async throws -> [BridgeProduct] {
try await bridge.sync()
let entitled = await bridge.currentEntitlements()
guard !entitled.isEmpty else { return [] }
return try await bridge.products(for: entitled)
}
| Layer | Tool | Covers |
|---|---|---|
| Unit tests | FakeStoreKitBridge (scripted outcomes + call counters) | Client logic — zero StoreKit dependency, runs in CI |
| Interactive local run | .storekit file wired into the Xcode scheme (Run → Options → StoreKit Configuration) | Manual purchase-flow smoke test, no sandbox Apple ID |
| Automated purchase-flow tests | StoreKitTest's SKTestSession (loads the same .storekit file) | XCUITest/integration-level flows against the real StoreKit stack |
A .storekit file is a testing fixture with no effect on a shipped build;
it's what enables the last two rows, not a gap in unit-test coverage if absent.
Product.products(for:) returns [], not a thrown error, for an unknown ID
(typo/sandbox drift) — decide what "no products" means for purchase()
before you hit it (one real app: .failed(reason: "product not found: <id>")
rather than a silent no-op). Practice observed.Transaction.updates/purchase-path switch on
Product.PurchaseResult needs @unknown default, not a plain default —
without it Swift 6 mode fails to compile ("switch covers known cases, but
'Product.PurchaseResult' may have additional unknown values"; a warning in
Swift 5 mode), and a plain default would silence the warning a case Apple
adds later should raise (Switching Over Future Enumeration
Cases);
recheck on every OS-support bump. Compiled-verified (Swift 6.3.2)..failed for a
purchase Apple already charged for; pair it with a telemetry hook so the
desync is observable. Practice observed.Task's priority is a real UX decision: a
refund/family-share event should flip entitlement state promptly while the
user may be in-session. .background deprioritizes it behind arbitrary
work; one real app shipped .background first and upgraded to .utility
after review. Practice observed.Provenance for the bridge/skeleton's verification claims: references/official-docs.md.
The bridge exists because Product/Transaction have no public
initializers — "test the untestable" is the first wall a from-scratch
StoreKit 2 implementation hits, not a hypothetical. Isolating import StoreKit to one file also keeps the client testable on CI runners without a
signed-in sandbox tester.
BridgeProduct's fields,
but keep currentEntitlements() a flat Set<String>.Transaction.subscriptionStatus and renewal-state handling this skill does
not cover.isPurchased instead of deriving it from currentEntitlements().finish(), or calling it before the entitlement is applied.Transaction.updates listener lazily instead of at launch.products(for:) returning [] as a thrown-error case.AppStore.sync() in restorePurchases() "because the cache is empty."@unknown default on the Product.PurchaseResult switch (Swift 6 mode
won't compile it), or a plain default that hides cases Apple adds later..storekit file as unit-test infrastructure — it configures
the interactive runtime and StoreKitTest, not the fake bridge.import StoreKit appears in exactly one file.currentEntitlements(), not stored as an
independent boolean.Transaction.updates listener starts at app launch.finish() is called after the entitlement is applied, on every path.restorePurchases() always calls sync() before reading entitlements.Product.PurchaseResult's switch has an @unknown default arm (not a
plain default).app-store-review-rejections).monetization-sdk-integration — same bridge-isolation pattern for ad SDKs.app-store-review-rejections — Restore Purchases / pricing-clarity review gate (3.1.1).asc-api-automation — TestFlight/App Store ops after the build exists.local-archive-export-upload / xcode-cloud-single-track-ci — shipping the binary.swift-dependency-injection — the general protocol-injection pattern this bridge instantiates.swift-testing-baseline — where this bridge's fake fits this catalog's test stack.apple-skills:storekit (aggregated external) — StoreKit 2 API reference incl. subscriptions, SubscriptionStoreView, renewal state — the part this skill does not cover.references/official-docs.md.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
storekit2, iap, in-app-purchase, swift, storekitbridge, non-consumable
npx claudepluginhub wei18/apple-dev-skills --plugin apple-dev-skills28 skills in this plugin
/ai-translated-localizationLocalization scope and AI-translation execution for Apple-platform Apps on `Localizable.xcstrings` — default locale set, source / primary language rule, per-locale review gotchas, completeness gates. Use when deciding which locales to ship at project setup; when adding or refreshing user-facing strings (UI keys, Game Center, App Store metadata) in non-source locales; when `extractionState: stale` entries or untranslated placeholder markers appear; or when asked "how many locales", "how do translations enter git". Does NOT cover RTL layout or ASC upload mechanics → asc-api-automation./apple-platform-targetsDefault minimum deployment target for Apple-platform Swift Apps — iOS 26 / macOS 26 on the Xcode 26 toolchain (Swift 6 language mode) — and how to deviate down (iOS 18 / 17) or up. Use when starting a new Apple-platform project, writing the Package.swift `platforms:` list, deciding whether an API newer than the floor is worth bumping for or a client requirement forces dropping below it, or when asked "what should the minimum iOS / macOS version be". Entry point of the bootstrap chain; does NOT own language mode → swift6-concurrency, or module layout → swiftpm-modularization./apple-public-repo-securityUse when a repo goes public or open-sources, when a CloudKit server-to-server PEM, ASC API `.p8`, APNs key, signing `.p12`, or provisioning profile first enters the pipeline, or when asked how to prevent or respond to a secret leak (gitleaks, lefthook, GitHub Secret Scanning, `git filter-repo`, rotate-first). Also for Apple upstream telemetry disclosure (MetricKit, Game Center, sysdiagnose). Repo-hygiene baseline only; ship-in-binary identifiers (AdMob IDs via xcconfig) and CLI keys in `secrets/.env` are build-time-secret-injection; ASC API usage is asc-api-automation./apple-three-piece-analyticsChoose analytics and metrics sources for a solo / small-team Apple app and decide whether a third-party tracking SDK is justified. Use when picking an analytics SDK; when asked "should I add Firebase / Mixpanel / Amplitude / TelemetryDeck"; when asked what App Store Connect Analytics, MetricKit (`MXMetricPayload`) or Game Center can measure without an SDK; when the analytics choice drives `PrivacyInfo.xcprivacy` or forces ATT. Does NOT own MetricKit perf wiring (ios-performance-engineering), App Review privacy-label parity (app-store-review-rejections), or sink code (telemetry-facade-pattern)./app-store-review-rejectionsUse when preparing an App Store submission, reading an App Review rejection or Resolution Center message citing a guideline number (2.1, 2.3.x, 3.1.1, 4.3, 5.1.1, 5.1.2), or a privacy-manifest upload email (ITMS-91061 / ITMS-91056, missing required-reason API), or auditing an ads + Remove-Ads IAP + CloudKit + Game Center app for the rejection classes it realistically hits: the ATT-vs-AdMob trap, privacy-label parity with `PrivacyInfo.xcprivacy`, Restore Purchases, screenshot metadata, export compliance. Maps each class to a pre-submit fix. Not the submission mechanics (asc-api-automation) nor StoreKit implementation (storekit2-iap-defaults)./asc-api-automationUse when automating App Store Connect from a script or CI via the ASC REST API (`api.appstoreconnect.apple.com`) — ASC API `.p8` key / JWT auth, TestFlight `betaGroups` / `betaBuildLocalizations`, `appStoreVersions` / `releaseType`, `reviewSubmissions`, `salesReports`, `analyticsReportRequests` — or asked "automate TestFlight / submission / release notes", "should I use fastlane", or debugging 401 NOT_AUTHORIZED / 429 RATE_LIMIT_EXCEEDED, or asked which ASC steps have no API and must be clicked by hand. API side only: build & upload → xcode-cloud-single-track-ci / local-archive-export-upload; `.p8` storage → build-time-secret-injection.Other plugins' skills for the same job