home / skills / rshankras / claude-code-apple-skills / paywall-generator

paywall-generator skill

/skills/generators/paywall-generator

This skill generates a complete StoreKit 2 subscription paywall with modern SwiftUI views and robust purchase handling.

npx playbooks add skill rshankras/claude-code-apple-skills --skill paywall-generator

Review the files below or copy the command above to add this skill to your agents.

Files (7)
SKILL.md
5.1 KB
---
name: paywall-generator
description: Generates StoreKit 2 subscription paywall with modern SwiftUI views. Use when user wants to add subscriptions, paywall, or in-app purchases.
allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion]
---

# Paywall Generator

Generate a complete StoreKit 2 subscription paywall with modern SwiftUI views, subscription status tracking, and proper purchase handling.

## When This Skill Activates

Use this skill when the user:
- Asks to "add subscriptions" or "add paywall"
- Mentions "in-app purchases" or "IAP"
- Wants "StoreKit 2" implementation
- Asks about "subscription management"
- Mentions "premium features" or "pro version"

## Pre-Generation Checks

### 1. Project Context Detection
- [ ] Check for existing StoreKit implementations
- [ ] Check deployment target (StoreKit 2 requires iOS 15+)
- [ ] Look for existing product IDs in codebase
- [ ] Identify source file locations

### 2. Conflict Detection
Search for existing StoreKit:
```
Glob: **/*Store*.swift, **/*Purchase*.swift, **/*Subscription*.swift
Grep: "import StoreKit" or "Product.products"
```

If found, ask user:
- Replace existing implementation?
- Extend with additional features?

## Apple Docs Reference

**Latest StoreKit Updates (iOS 18.4+):**
- `SubscriptionOfferView` - New SwiftUI view for merchandising subscriptions
- `subscriptionStatusTask` modifier for tracking subscription state
- `Transaction.currentEntitlements(for:)` - New API for entitlements
- `RenewalInfo` enhancements for expiration reasons

## Configuration Questions

Ask user via AskUserQuestion:

1. **Subscription tiers?** (multi-select)
   - Monthly
   - Yearly (with discount)
   - Lifetime
   - Weekly

2. **Features needed?**
   - Free trial
   - Family sharing
   - Promotional offers

3. **UI style?**
   - Full paywall screen
   - Inline subscription view
   - Both

## Generation Process

### Step 1: Create Core Files

Generate these files:
1. `StoreKitManager.swift` - Product loading and purchasing
2. `SubscriptionStatus.swift` - Status tracking
3. `PaywallView.swift` - Full paywall UI
4. `SubscriptionButton.swift` - Individual plan button

### Step 2: Create Configuration

- `Products.swift` - Product ID constants

### Step 3: Determine File Location

Check project structure:
- If `Sources/` exists → `Sources/Store/`
- If `App/` exists → `App/Store/`
- Otherwise → `Store/`

## Product ID Setup

### App Store Connect

1. Go to App Store Connect > Your App > Subscriptions
2. Create subscription group
3. Add subscription products with IDs like:
   - `com.yourapp.subscription.monthly`
   - `com.yourapp.subscription.yearly`
   - `com.yourapp.subscription.lifetime`

### StoreKit Configuration (Testing)

Create `Products.storekit` for local testing:
1. File > New > File > StoreKit Configuration
2. Add products matching your IDs
3. Edit scheme > Options > StoreKit Configuration

## Output Format

After generation, provide:

### Files Created
```
Sources/Store/
├── StoreKitManager.swift        # Product loading & purchasing
├── SubscriptionStatus.swift     # Status enum & tracking
├── Products.swift               # Product ID constants
└── Views/
    ├── PaywallView.swift        # Full paywall screen
    ├── SubscriptionButton.swift # Plan selection button
    └── SubscriptionOfferCard.swift # New iOS 18.4+ view
```

### Integration Steps

**App Entry Point:**
```swift
@main
struct MyApp: App {
    @State private var subscriptionStatus: SubscriptionStatus = .unknown

    var body: some Scene {
        WindowGroup {
            ContentView()
                .environment(\.subscriptionStatus, subscriptionStatus)
                .subscriptionStatusTask(for: "your.group.id") { statuses in
                    subscriptionStatus = SubscriptionStatus.from(statuses)
                }
        }
    }
}
```

**Show Paywall:**
```swift
struct ContentView: View {
    @State private var showPaywall = false
    @Environment(\.subscriptionStatus) var status

    var body: some View {
        VStack {
            if status != .subscribed {
                Button("Upgrade to Pro") {
                    showPaywall = true
                }
            }
        }
        .sheet(isPresented: $showPaywall) {
            PaywallView()
        }
    }
}
```

**New iOS 18.4+ SubscriptionOfferView:**
```swift
// Simple merchandising view
SubscriptionOfferView(productID: "com.app.subscription.monthly")
    .prefersPromotionalIcon(true)
    .subscriptionOfferViewDetailAction {
        showPaywall = true
    }
```

### Testing Instructions

1. **Create StoreKit Configuration:**
   - File > New > StoreKit Configuration
   - Add your products

2. **Edit Scheme:**
   - Product > Scheme > Edit Scheme
   - Options > StoreKit Configuration > Select your file

3. **Test Purchases:**
   - Run in Simulator
   - Use Transaction Manager (Debug > StoreKit > Transaction Manager)

4. **Test Scenarios:**
   - Purchase flow
   - Restore purchases
   - Subscription expiration
   - Renewal

## References

- **storekit-patterns.md** - Best practices and patterns
- **templates/** - All template files
- Apple Docs: StoreKit Updates (iOS 18.4+)

Overview

This skill generates a complete StoreKit 2 subscription paywall implemented with modern SwiftUI views, subscription status tracking, and purchase handling. It scaffolds core files, product ID configuration, and optional iOS 18.4+ SubscriptionOfferView support. Use it to add, replace, or extend subscription flows quickly and correctly for iOS 15+ projects.

How this skill works

The generator inspects the project for existing StoreKit implementations and deployment target constraints, then creates a small set of core files (StoreKitManager, SubscriptionStatus, Products) plus SwiftUI views for a full paywall and per-plan buttons. It wires subscription status updates using StoreKit 2 APIs and includes patterns for local StoreKit configuration for testing. The output includes integration snippets to add subscriptionStatusTask and a sheet-based PaywallView entry point.

When to use it

  • You want to add a subscription paywall or upgrade flow to an iOS app.
  • Implementing StoreKit 2-based in-app purchases and entitlement tracking.
  • You need ready-made SwiftUI paywall screens and purchase handling.
  • Adding modern iOS 18.4+ merchandising with SubscriptionOfferView.
  • Replacing or extending an existing purchases implementation.

Best practices

  • Verify project deployment target is iOS 15+ before generating StoreKit 2 code.
  • Scan repo for existing StoreKit files and decide to replace or extend to avoid conflicts.
  • Create a Products.storekit file for local testing and add matching product IDs.
  • Keep product IDs in a central Products.swift constant file for maintainability.
  • Use subscriptionStatusTask and Transaction.currentEntitlements(for:) for reliable entitlement state.

Example use cases

  • Generate full paywall screens (PaywallView, SubscriptionButton) and integrate via a sheet from ContentView.
  • Add a lightweight inline subscription module for an onboarding screen.
  • Scaffold backend for monthly, yearly, and lifetime subscription tiers with product ID constants.
  • Enable local StoreKit testing quickly by creating a Products.storekit and editing the test scheme.
  • Add iOS 18.4+ SubscriptionOfferView merchandising while using the same purchase manager.

FAQ

What deployment target is required?

StoreKit 2 requires iOS 15 or later; some newer UI helpers like SubscriptionOfferView need iOS 18.4+.

Will this overwrite existing StoreKit code?

The generator checks for existing StoreKit files and should ask whether to replace or extend; review conflicts before applying changes.