Autumn Sale50% offCOMPOT

SwiftUI Paywalls & Subscriptions

Benefit rows with checkmarks, cascading bounce animations, and selectable subscription plan choices. (3 components available in Compot).

1 of 3Free ComponentiOS 16.0+

Benefit Row Basic

Single paywall feature row with colored checkmark and benefit description.

View Component & Details
BenefitRowBasic.swift
import SwiftUI

struct BenefitRowBasic: View {
    var body: some View {
        HStack(spacing: 12) {
            Image(systemName: "checkmark.circle.fill")
            .foregroundStyle(Color.accentColor)
            .symbolRenderingMode(.multicolor)
            .font(.system(size: 22, weight: .medium))
            Text("Benefit description")
            .multilineTextAlignment(.leading)
        }
        .font(.system(size: 17, weight: .medium))
        .frame(alignment: .leading)
    }
}

#Preview {
    BenefitRowBasic()
}
2 of 3Pro ComponentiOS 16.0+

Pro Benefits VStack with Bounce

Complete paywall feature list with cascading spring-in bounce animations.

View Component & Details
ProBenefitsVstackWithBounce.swift
Unlock in App
import SwiftUI

struct ProBenefitsWBounce: View {
    
    @State private var bounce1: Bool = false
    @State private var bounce2: Bool = false
    @State private var bounce3: Bool = false
    

        // ...
        // Complete source code available in Compot Pro on the App Store.
Compot Pro Component

Unlock full code & interactive preview

Interactive live preview and complete SwiftUI code available in the Compot App.

Available for macOS & iOS • 85+ free components included

3 of 3Pro ComponentiOS 16.0+

Subscription Plan Choice with Checkmark

Selectable pricing tier card (Monthly vs. Annual) with radio checkmark and "Save 50%" tag.

View Component & Details
SubscriptionPlanChoiceWithCheckmark.swift
Unlock in App
import SwiftUI

struct SubscriptionPlanBanner: View {
    
    @State private var isSelected: Bool = false
    
    let planTitle: String = "Compot Pro Annual Subscription"
    let planPrice: String = "$9.99/year, then $29.99/year"

        // ...
        // Complete source code available in Compot Pro on the App Store.
Compot Pro Component

Unlock full code & interactive preview

Interactive live preview and complete SwiftUI code available in the Compot App.

Available for macOS & iOS • 85+ free components included

Production Architecture

StoreKit 2, Subscription Presentation & Accessibility

Building a high-converting iOS paywall requires more than visual polish. This guide outlines modern StoreKit 2 transaction handling, resilient purchase and restore states, App Store Review Guideline 3.1.2 compliance, and inclusive accessibility practices.

API & Concurrency

StoreKit 2 Practical Architecture

StoreKit 2 replaces legacy SKPaymentQueue with async/await, typed transactions, and cryptographic JWS verification.

  • Query products asynchronously with Product.products(for: ids) rather than SKProductsRequest delegates.
  • Always verify transactions with VerificationResult before unlocking features to prevent receipt spoofing.
  • Call await transaction.finish() immediately after delivering digital entitlements.
  • Listen to Transaction.updates in the app lifecycle so out-of-app renewals, family approvals, and revocations sync in real time.
State Machine

Purchase & Restore States

Robust paywalls explicitly model idle, in-flight, deferred, error, and restored states to ensure seamless user feedback.

  • Model state with an enum: idle, purchasing(productID), restoring, pending, failed(message), and success.
  • Treat Product.PurchaseResult.userCancelled as a graceful return to idle without showing an error dialog.
  • Handle .pending status for Ask to Buy parental controls and inform the user that approval is pending.
  • Implement restore with try await AppStore.sync() and iterate Transaction.currentEntitlements.
App Store 3.1.2

Subscription Presentation & Review Guidelines

Apple enforces strict pricing transparency rules under App Store Review Guideline 3.1.2 before approving subscription apps.

  • Clearly state plan duration, recurring price, and the exact terms of introductory offers or free trials.
  • Present functional, direct links to both your Terms of Use (EULA) and Privacy Policy on the paywall screen.
  • Highlight comparative savings (e.g. "Save 50% vs Monthly") transparently alongside total billed amount.
  • Provide deep links to manage subscriptions using manageSubscriptionsSheet or AppStore.showManageSubscriptions(in:).
WCAG 2.2 & HIG

Accessibility Considerations

Paywalls must remain fully operable under Dynamic Type, VoiceOver, and Reduce Motion settings.

  • Dynamic Type: Avoid fixed height frames on plan cards. Allow text to wrap naturally with vertical flexibility.
  • VoiceOver: Wrap tier cards in .accessibilityElement(children: .combine) and assign .accessibilityAddTraits(.isSelected).
  • Provide comprehensive accessibility labels articulating the plan duration, price, and savings in plain words.
  • Reduce Motion: Check @Environment(\.accessibilityReduceMotion) to disable or soften bounce/spring animations.

Purchase & Restore State Machine

Model paywall interactions using an explicit state enum to keep SwiftUI render trees predictable and avoid race conditions or unhandled failures:

.idle

Default state. User can select plans, read benefit rows, or trigger purchase/restore.

.purchasing(productID)

StoreKit purchase sheet active. Disable secondary buttons and show ProgressView in CTA.

.restoring

AppStore.sync() syncing entitlements. Displays spinner on restore button to indicate background query.

.success

Cryptographically verified JWS transaction confirmed. Dismiss paywall and unlock Pro privileges.

.pending

Deferred transaction (e.g. Ask to Buy parent authorization). Informs user without triggering hard failure.

.failed(message)

Real network or App Store error. Display clear alert dialog. Handle .userCancelled silently without error.

Two Production-Ready SwiftUI Reference Implementations

Copy these standalone, dependency-free reference examples directly into your Xcode project. Both support iOS 16, 17, and 18.

Example 1Free ReferenceiOS 16.0+

SubscriptionTierPicker — Accessible Plan Selector

Demonstrates dual-tier pricing (Annual vs. Monthly) with savings tag, Dynamic Type support, VoiceOver grouping with .accessibilityElement(children: .combine), the .isSelected trait, and Reduce Motion awareness.

SubscriptionTierPicker.swift
import SwiftUI
import StoreKit

/// Model representing a selectable subscription option.
struct SubscriptionPlanTier: Identifiable, Hashable {
    let id: String
    let title: String
    let priceText: String
    let billingDetail: String
    let badge: String?
    let accessibilityText: String
}

/// Accessible, Dynamic Type-compatible subscription plan selector.
struct SubscriptionTierPicker: View {
    @Binding var selectedPlanID: String
    let tiers: [SubscriptionPlanTier]
    
    @Environment(\.accessibilityReduceMotion) private var reduceMotion
    
    var body: some View {
        VStack(spacing: 12) {
            ForEach(tiers) { tier in
                let isSelected = selectedPlanID == tier.id
                
                Button {
                    select(tier.id)
                } label: {
                    HStack(alignment: .center, spacing: 14) {
                        Image(systemName: isSelected ? "checkmark.circle.fill" : "circle")
                            .font(.title3)
                            .foregroundStyle(isSelected ? Color.accentColor : Color.secondary)
                        
                        VStack(alignment: .leading, spacing: 4) {
                            HStack(spacing: 8) {
                                Text(tier.title)
                                    .font(.headline)
                                    .foregroundStyle(.primary)
                                
                                if let badge = tier.badge {
                                    Text(badge)
                                        .font(.caption2.weight(.bold))
                                        .padding(.horizontal, 8)
                                        .padding(.vertical, 2)
                                        .background(Color.accentColor.opacity(0.15))
                                        .foregroundStyle(Color.accentColor)
                                        .clipShape(Capsule())
                                }
                            }
                            
                            Text(tier.billingDetail)
                                .font(.subheadline)
                                .foregroundStyle(.secondary)
                        }
                        
                        Spacer(minLength: 8)
                        
                        Text(tier.priceText)
                            .font(.headline)
                            .foregroundStyle(.primary)
                            .multilineTextAlignment(.trailing)
                    }
                    .padding(16)
                    .frame(maxWidth: .infinity, alignment: .leading)
                    .background {
                        RoundedRectangle(cornerRadius: 16, style: .continuous)
                            .fill(isSelected ? Color.accentColor.opacity(0.08) : Color(.secondarySystemBackground))
                    }
                    .overlay {
                        RoundedRectangle(cornerRadius: 16, style: .continuous)
                            .strokeBorder(isSelected ? Color.accentColor : Color.clear, lineWidth: 2)
                    }
                }
                .buttonStyle(.plain)
                .contentShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
                // VoiceOver: combine children, announce selection and action hint
                .accessibilityElement(children: .combine)
                .accessibilityLabel(tier.accessibilityText)
                .accessibilityAddTraits(isSelected ? [.isButton, .isSelected] : .isButton)
                .accessibilityHint(isSelected ? "Currently selected plan." : "Double tap to select this plan.")
                .animation(reduceMotion ? nil : .easeInOut(duration: 0.2), value: isSelected)
            }
        }
        .frame(maxWidth: 500)
    }
    
    private func select(_ id: String) {
        #if os(iOS)
        UISelectionFeedbackGenerator().selectionChanged()
        #endif
        selectedPlanID = id
    }
}

#Preview {
    @Previewable @State var selected = "annual"
    let mockTiers: [SubscriptionPlanTier] = [
        SubscriptionPlanTier(
            id: "annual",
            title: "Annual Access",
            priceText: "$29.99/yr",
            billingDetail: "7-day free trial, then $2.49/mo",
            badge: "SAVE 50%",
            accessibilityText: "Annual Access, 29 dollars and 99 cents per year, includes 7-day free trial, then 2 dollars and 49 cents per month. Save 50 percent."
        ),
        SubscriptionPlanTier(
            id: "monthly",
            title: "Monthly Access",
            priceText: "$4.99/mo",
            billingDetail: "Billed monthly, cancel anytime",
            badge: nil,
            accessibilityText: "Monthly Access, 4 dollars and 99 cents per month, billed monthly. Cancel anytime."
        )
    ]
    
    return SubscriptionTierPicker(selectedPlanID: $selected, tiers: mockTiers)
        .padding()
}
Accessibility Engineering:VoiceOver groups title, price, period, and savings into a single coherent utterance, avoiding fragmented focus stops. .accessibilityAddTraits(.isSelected) allows screen reader users to instantly identify the chosen option.
Dynamic Type Layout:Omits hardcoded vertical heights so containers grow naturally as users increase font sizes in Settings, preventing truncated pricing copy.
Example 2Free ReferenceiOS 16.0+

StoreKitPaywallCoordinator — Purchase & Restore States

Demonstrates asynchronous transaction initiation with product.purchase(), JWS cryptographic signature verification, restore handling via AppStore.sync(), loading feedback, error alerts, and required App Store Guideline 3.1.2 legal links.

StoreKitPaywallCoordinator.swift
import SwiftUI
import StoreKit

/// Explicit purchase and restore states for StoreKit 2 paywalls.
enum PaywallActionState: Equatable {
    case idle
    case purchasing(productID: String)
    case restoring
    case pending
    case failed(message: String)
    case success
}

/// StoreKit 2 Paywall Coordinator handling purchase execution, restore, and states.
struct StoreKitPaywallCoordinator: View {
    @State private var state: PaywallActionState = .idle
    @State private var selectedProductID: String = "com.compot.pro.annual"
    @State private var showingErrorAlert = false
    @State private var errorMessage = ""
    @State private var showManageSubscriptions = false
    
    let termsURL = URL(string: "https://www.compotui.com/terms")!
    let privacyURL = URL(string: "https://www.compotui.com/privacy")!
    
    var isProcessing: Bool {
        switch state {
        case .purchasing, .restoring:
            return true
        default:
            return false
        }
    }
    
    var body: some View {
        VStack(spacing: 20) {
            // Main Call-to-Action button with loading indicator
            Button {
                Task {
                    await startPurchase(productID: selectedProductID)
                }
            } label: {
                HStack(spacing: 8) {
                    if case .purchasing = state {
                        ProgressView()
                            .tint(.white)
                    }
                    Text(buttonTitle)
                        .font(.headline)
                        .fontWeight(.semibold)
                }
                .frame(maxWidth: .infinity)
                .frame(height: 52)
                .background(Color.accentColor)
                .foregroundStyle(.white)
                .clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous))
            }
            .disabled(isProcessing)
            
            // Restore Purchases Action
            Button {
                Task {
                    await restorePurchases()
                }
            } label: {
                HStack(spacing: 6) {
                    if state == .restoring {
                        ProgressView()
                            .controlSize(.small)
                    }
                    Text("Restore Purchases")
                        .font(.subheadline)
                        .foregroundStyle(.secondary)
                }
            }
            .disabled(isProcessing)
            
            // App Store Guideline 3.1.2 required legal links and management
            HStack(spacing: 16) {
                Link("Terms of Use", destination: termsURL)
                Text("•")
                    .foregroundStyle(.secondary)
                Link("Privacy Policy", destination: privacyURL)
                Text("•")
                    .foregroundStyle(.secondary)
                Button("Manage Subscriptions") {
                    showManageSubscriptions = true
                }
            }
            .font(.footnote)
            .foregroundStyle(.secondary)
        }
        .padding()
        .frame(maxWidth: 480)
        .manageSubscriptionsSheet(isPresented: $showManageSubscriptions)
        .alert("Unable to Complete Transaction", isPresented: $showingErrorAlert) {
            Button("OK", role: .cancel) {
                state = .idle
            }
        } message: {
            Text(errorMessage)
        }
    }
    
    private var buttonTitle: String {
        switch state {
        case .purchasing:
            return "Processing Purchase…"
        case .restoring:
            return "Restoring Purchases…"
        case .success:
            return "Subscribed"
        default:
            return "Start 7-Day Free Trial"
        }
    }
    
    @MainActor
    private func startPurchase(productID: String) async {
        state = .purchasing(productID: productID)
        
        do {
            let products = try await Product.products(for: [productID])
            guard let product = products.first else {
                throw PaywallError.productNotFound
            }
            
            let result = try await product.purchase()
            
            switch result {
            case .success(let verification):
                let transaction = try checkVerified(verification)
                await transaction.finish()
                state = .success
                
            case .userCancelled:
                state = .idle
                
            case .pending:
                state = .pending
                errorMessage = "Purchase is pending approval from family organizer."
                showingErrorAlert = true
                
            @unknown default:
                state = .idle
            }
        } catch {
            state = .failed(message: error.localizedDescription)
            errorMessage = error.localizedDescription
            showingErrorAlert = true
        }
    }
    
    @MainActor
    private func restorePurchases() async {
        state = .restoring
        
        do {
            try await AppStore.sync()
            
            var hasActiveSubscription = false
            for await result in Transaction.currentEntitlements {
                if case .verified(let transaction) = result {
                    if transaction.revocationDate == nil {
                        hasActiveSubscription = true
                        break
                    }
                }
            }
            
            if hasActiveSubscription {
                state = .success
            } else {
                state = .idle
                errorMessage = "No active subscriptions found for this Apple ID."
                showingErrorAlert = true
            }
        } catch {
            state = .failed(message: error.localizedDescription)
            errorMessage = error.localizedDescription
            showingErrorAlert = true
        }
    }
    
    private func checkVerified<T>(_ result: VerificationResult<T>) throws -> T {
        switch result {
        case .unverified(_, let error):
            throw error
        case .verified(let safe):
            return safe
        }
    }
}

enum PaywallError: LocalizedError {
    case productNotFound
    
    var errorDescription: String? {
        switch self {
        case .productNotFound:
            return "The selected product could not be loaded from the App Store."
        }
    }
}

#Preview {
    StoreKitPaywallCoordinator()
}
App Store Guideline 3.1.2:Direct, functional links to your Privacy Policy and Terms of Use (EULA) are visible on the paywall screen before any purchase attempt, satisfying Apple review requirements.
Resilient Concurrency:Wraps async StoreKit 2 calls in @MainActor tasks, gracefully drops .userCancelled without throwing false-alarm error alerts, and surfaces deferred Ask to Buy requests.

Subscription Paywall Pre-Submission Checklist

Verify these five items before submitting an iOS app with auto-renewable subscriptions to App Store Review:

1
Explicit Plan Duration and Recurring Cost
State the recurring billing cadence (e.g. “$29.99 per year”) clearly. Do not show only the monthly breakdown if the user is billed annually up front.
2
Clear Free Trial Terms
If offering a free trial, explicitly state the duration (e.g. “7 days free”) and what the renewal cost will be once the trial expires.
3
Visible Privacy Policy & Terms of Use Links
Both links must be operable directly from the paywall view without requiring the user to tap purchase or navigate away from the app.
4
Functional Restore Purchases Mechanism
Provide an obvious “Restore Purchases” button powered by AppStore.sync() or entitlement inspection. Apple rejects apps lacking a visible restore trigger.
5
Accessible Typography and Hit Targets
Ensure buttons and cards meet the minimum 44×44 pt touch target and that Dynamic Type scaling does not cause prices or legal disclosures to overlap or clip.