The Swift Kit logoThe Swift Kit

How to Add RevenueCat to SwiftUI: Complete StoreKit 2 Integration Guide

Want to monetize your iOS app with subscriptions? This guide shows you how to add RevenueCat to SwiftUI, explains StoreKit 2 vs RevenueCat, and includes ready-to-use SwiftUI paywall templates.

StoreKit 2 vs RevenueCat: Which Should You Use?

This is the most common question from indie iOS developers. Here's the breakdown:

FeatureStoreKit 2 (Native)RevenueCat
Server-side receipt validationManualAutomatic ✓
Cross-platform supportiOS onlyiOS, Android, Web ✓
Analytics dashboardApp Store ConnectRich dashboard ✓
A/B testing paywallsNoYes ✓
PriceFree ✓Free up to $2.5K MRR
Setup complexityHighLow ✓

The verdict: Use RevenueCat on top of StoreKit 2. You get native Apple purchases with RevenueCat's subscription management, analytics, and server-side validation. That's exactly how The Swift Kit is set up.

How to Add RevenueCat to SwiftUI — Step by Step

Step 1: Install the SDK

Add RevenueCat/purchases-ios via Swift Package Manager.

Step 2: Configure on Launch

// App.swift
import RevenueCat

@main
struct MyApp: App {
  init() {
    Purchases.configure(
      withAPIKey: "YOUR_REVENUECAT_API_KEY"
    )
  }
}

Step 3: Fetch Offerings

// PaywallViewModel.swift
@Published var offerings: Offerings?

func loadOfferings() async {
  offerings = try? await Purchases.shared.offerings()
}

Step 4: Build a SwiftUI Paywall Template

Create a paywall view that displays packages from your offerings with pricing, trial info, and a purchase button. The Swift Kit includes three pre-built SwiftUI paywall templates so you don't have to build this from scratch.

Step 5: Handle Purchases & Entitlements

// Purchase a package
let result = try await Purchases.shared.purchase(package: package)

// Check entitlement
let customerInfo = try await Purchases.shared.customerInfo()
let isPro = customerInfo.entitlements["pro"]?.isActive == true

Skip the Manual Setup — Use The Swift Kit

The Swift Kit includes RevenueCat fully pre-integrated with StoreKit 2. You get paywall templates, subscription management, trial flows, restore purchases, and entitlement handling — all wired up. Just paste your RevenueCat API key and you're done.