RevenueCat/purchases-ios
关于
轻松实现应用内购买和订阅。支持 iOS、watchOS、tvOS、macOS 和 visionOS。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- +2
- 15天
- +6
- 1个月
- +11
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文purchases-ios
The RevenueCat SDK for Apple platforms. It wraps StoreKit and handles purchases, entitlements, and subscription status.
Docs · Install guide · SDK reference · Sample app · Changelog · Migration guide
Requirements
| Requirement | Minimum |
|---|---|
| iOS | 13.0 |
| iPadOS | 13.0 |
| macOS | 10.15 |
| Mac Catalyst | Supported |
| tvOS | 13.0 |
| watchOS | 6.2 |
| visionOS | 1.0 |
| Xcode | 15.0 |
Paywalls need iOS 15, Mac Catalyst 15, or macOS 12 or later. macOS doesn't support legacy paywalls. Customer Center needs iOS 15 or Mac Catalyst 15 or later. Neither is available on tvOS, watchOS, or visionOS.
Installation
Install with Swift Package Manager. In Xcode, choose File > Add Package Dependencies and enter this URL:
https://github.com/RevenueCat/purchases-ios-spm.git
Set Dependency Rule to Up to Next Major Version from 5.0.0, then add the RevenueCat product to your app target. Add RevenueCatUI too if you show Paywalls or Customer Center. Use purchases-ios-spm.git throughout your project. Referencing both it and purchases-ios.git causes duplicate-target errors.
Then add the In-App Purchase capability under Signing & Capabilities. Test Store purchases work without it.
- CocoaPods: releases end December 2, 2026, and existing versions stay available. To keep getting updates, migrate to Swift Package Manager.
- Carthage: add
github "revenuecat/purchases-ios"to your Cartfile and runcarthage update --use-xcframeworks. See the Carthage steps.
| Package | What it's for | When you need it |
|---|---|---|
RevenueCat |
Purchases, entitlements, subscription status | Always |
RevenueCatUI |
Paywalls and Customer Center | You show RevenueCat Paywalls or Customer Center |
RevenueCatAdMob |
Tracks AdMob ad events in RevenueCat | You show AdMob ads. Separate package; needs iOS 15 or later |
Quick start
Before you start, create a RevenueCat project, connect your store or start with the Test Store, and add an entitlement. See the Quickstart.
Configure Purchases once at app launch with your public API key (the Test Store key while you test). Omit appUserID to have RevenueCat generate an anonymous ID. This SwiftUI example needs iOS 14 or later. If your app targets iOS 13, configure in your app delegate instead, as in MagicWeather's AppDelegate.
import SwiftUI
import RevenueCat
@main
struct SampleApp: App {
init() {
Purchases.logLevel = .debug
Purchases.configure(withAPIKey: <public_apple_api_key>, appUserID: <app_user_id>)
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Check whether the user has an active entitlement before you show a paywall:
let customerInfo = try await Purchases.shared.customerInfo()
if customerInfo.entitlements.all[<your_entitlement_id>]?.isActive == true {
// User is "premium"
}
What's included
- Paywalls: build single-screen or multi-step paywalls in the dashboard and change them without an app update.
- Customer Center: a self-service screen where users cancel, restore purchases, request refunds, and change plans.
- Placements: serve a different Offering at each paywall location in your app.
- Test Store: test purchases before you set up App Store Connect.
- In-app currency: read the current Customer's in-app currency balances.
- Redemption Links: unlock a web purchase in your app from a deep link.
- iOS subscription offers: promotional offers, the offer code redemption sheet, and win-back offers.
- Your own purchase code: set
purchasesAreCompletedByto keep completing purchases with your existing StoreKit code. - Offline entitlements: the SDK grants entitlements for new subscription purchases while RevenueCat's servers are down. It's unavailable when your app completes purchases itself.
- Trusted Entitlements: the SDK checks a signature on entitlement data so your app can detect tampered responses. It runs in informational mode by default: it reports the result and doesn't block access.
- Ad Monetization: report ad impressions, clicks, and revenue next to subscription data (iOS 15 or later). The AdMob adapter tracks AdMob events automatically.
Documentation
- Install guide: Swift Package Manager, CocoaPods, and Carthage steps, and the In-App Purchase capability.
- Configure the SDK: initialization, debug logs, Test Store, and other configuration options.
- Displaying paywalls: present a paywall from SwiftUI or UIKit.
- Testing purchases: Test Store and sandbox testing.
- Migration guide: changes in the current major version.
- SDK reference: every public class and method in the
RevenueCatmodule.
Using an AI coding agent
Your agent's training data is likely older than the current version of this SDK. Point it at current sources:
- llms.txt: an index of the docs. Add
.mdto any docs URL for a Markdown version. - RevenueCat MCP server: lets your agent read and change your RevenueCat project configuration.
- AI Toolkit: installs RevenueCat skills and the MCP server in one step.
- Releases: check the latest version before adding the dependency.
Sample apps
- MagicWeather: a UIKit app that configures the SDK, shows a paywall, checks subscription status, and restores purchases.
- MagicWeatherSwiftUI: a SwiftUI app that configures the SDK, builds a custom paywall from Offerings, checks subscription status, and restores purchases.
Getting help
- Bugs: open an issue in this repo.
- Account or configuration questions: RevenueCat Support.
- Discussion: RevenueCat Community.
Contributing
This repository is published from the main branch and release tags of RevenueCat's internal development repository. Issues are tracked here. Pull requests are welcome: a maintainer reviews them here and brings accepted changes into the internal repository, so they can't be merged directly.
See the contributing guide.
For iOS paywalls and workflows, use unit tests for SDK logic, PaywallFixtures for offline interaction tests, and Emerge snapshots for visual changes. Maestro checks complete app flows. PerformanceTests measures peak memory. The workflow runner measures main-thread CPU during presentation and navigation. See the iOS test guide for local commands and PR checks.
License
MIT. See LICENSE.
探索相关项目
加载中…