重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
storekit by johnrogers/claude-swift-engineering
npx skills add https://github.com/johnrogers/claude-swift-engineering --skill storekit广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 交易监听器、验证、完成交易、恢复购买 |
| StoreKit 视图 | SwiftUI 中的 ProductView、SubscriptionStoreView、SubscriptionOfferView |
.storekit 配置文件(在任何代码之前)@MainActor 实现集中式 StoreManagerTransaction.updates 监听器ProductView 或自定义 UI 显示产品transaction.finish()@MainActor
final class StoreManager: ObservableObject {
@Published private(set) var products: [Product] = []
@Published private(set) var purchasedProductIDs: Set<String> = []
private var transactionListener: Task<Void, Never>?
init() {
transactionListener = listenForTransactions()
Task { await loadProducts() }
}
}
遗漏交易的 .finish() 调用 — 授予权益后忘记调用 transaction.finish() 会导致交易永远无法完成。用户将看不到他们的购买反映出来。务必调用 finish()。
不安全的 StoreManager 状态 — 没有 @MainActor 的共享 StoreManager 可能存在竞态条件。多个异步任务可能并发更新 @Published 属性,破坏状态。使用 @MainActor 确保线程安全。
应用启动时没有交易监听器 — 不设置 Transaction.updates 监听器意味着应用崩溃或错过退款/取消的购买。应在 @main 中立即监听交易,而不是在用户点击购买按钮时。
硬编码产品 ID — 硬编码 ID 使得测试和本地化变得困难。使用配置文件或环境变量来管理产品 ID。价格也同样适用(从 App Store 获取,不要硬编码)。
忽略验证失败 — App Store 验证有时会静默失败。不检查验证状态意味着接受未经验证的交易(安全风险)。授予权益前务必进行验证。
54
179
2026年1月23日
codex42
opencode41
claude-code40
gemini-cli36
cursor35
github-copilot34
StoreKit 2 patterns for implementing in-app purchases with async/await APIs, automatic verification, and SwiftUI integration.
ALWAYS load reference files if there is even a small chance the content may be required. It's better to have the context than to miss a pattern or make a mistake.
| Reference | Load When |
|---|---|
| Getting Started | Setting up .storekit configuration file, testing-first workflow |
| Products | Loading products, product types, purchasing with Product.purchase() |
| Subscriptions | Auto-renewable subscriptions, subscription groups, offers, renewal tracking |
| Transactions | Transaction listener, verification, finishing transactions, restore purchases |
| StoreKit Views | ProductView, SubscriptionStoreView, SubscriptionOfferView in SwiftUI |
.storekit configuration file first (before any code)StoreManager with @MainActorTransaction.updates listener at app launchProductView or custom UItransaction.finish() after granting entitlements@MainActor
final class StoreManager: ObservableObject {
@Published private(set) var products: [Product] = []
@Published private(set) var purchasedProductIDs: Set<String> = []
private var transactionListener: Task<Void, Never>?
init() {
transactionListener = listenForTransactions()
Task { await loadProducts() }
}
}
Missing.finish() calls on transactions — Forgetting to call transaction.finish() after granting entitlements causes transactions to never complete. The user won't see their purchase reflected. Always call finish().
Unsafe StoreManager state — Shared StoreManager without @MainActor can have race conditions. Multiple async tasks can update @Published properties concurrently, corrupting state. Use @MainActor for thread safety.
No transaction listener at app launch — Not setting up Transaction.updates listener means app crashes or misses refunded/canceled purchases. Listen for transactions immediately in , not when user taps purchase button.
Weekly Installs
54
Repository
GitHub Stars
179
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex42
opencode41
claude-code40
gemini-cli36
cursor35
github-copilot34
@mainHardcoded product IDs — Hardcoded IDs make testing and localization hard. Use configuration files or environment variables for product IDs. Same applies to prices (fetch from App Store, don't hardcode).
Ignoring verification failures — App Store verification fails silently sometimes. Not checking verification status means accepting unverified transactions (security risk). Always verify before granting entitlements.