Add In-App Subscriptions to a SwiftUI Twitter Clone: Subscription Platform + Stream Walkthrough
A social-app clone is a useful sandbox for subscription work because the paywall sits behind a real feature gate. This walkthrough follows the subscription portion of the Stream Twitter-clone project: you create a subscription-platform account and project, define a product in App Store Connect, mirror it in the platform under a named entitlement, add the SDK through Tuist, and then read entitlement state and offer a purchase in a SwiftUI paywall view. The whole path is short, but each stage hands a specific value to the next one, and that handoff is where most setup mistakes happen.
What this walkthrough covers
The Stream project builds a Twitter-style app with SwiftUI and delegates discrete features to third-party platforms: chat and activity feeds, search, audio rooms, video playback, and subscriptions. This page focuses only on the subscription slice. It assumes the app shell already exists and that you are adding a paid tier on top of it.
The sequence has five stages, and each one produces something the next stage consumes:
- Create a subscription-platform account.
- Create a project in the platform dashboard and add your app with the App Store platform selected.
- Create the subscription product in App Store Connect and note its product ID.
- Create a matching product in the platform and attach it to an entitlement.
- Add the platform SDK to the Tuist project, then read entitlement state and offer a purchase in SwiftUI.
A useful habit before you start: keep a scratch note with three values — the App Store Connect product ID, the entitlement identifier, and the platform public API key. Every later step references at least one of them.
Stage 1–2: Account, project, and app platform
Sign up for a subscription-platform account, then open the dashboard and add a new project from the Projects dropdown in the top navigation. Inside that project, add an app, choose App Store as the platform, and give it a name. The remaining app details can wait until you have the store-side product in hand.
The original tutorial's authors recommend a separate account for each distinct project or app, noting that this makes selling or transferring ownership easier later. That is their recommendation, not a technical requirement of the SDK; follow it if you expect to hand the app off, and treat it as optional otherwise.
At the end of this stage you should have: a project, an app record with the App Store platform selected, and a place in the dashboard where products and entitlements will live.
Stage 3: The App Store Connect product
Create the subscription in App Store Connect following the platform's official iOS product setup documentation. The important output of this stage is the product ID for the subscription you created — write it down, because the platform product you create next must reference it.
In the Stream project the paid tier is presented as a Twitter Blue–style subscription. The exact product identifier is whatever you create in your own App Store Connect account; the tutorial's identifier is not a value you should reuse.
Stage 4: Mirror the product in subscription management platform and name the entitlement
Return to the platform dashboard and create a product that matches the App Store Connect product. Then create an entitlement and attach the product to it. The platform's own product-configuration and entitlements documentation covers the dashboard steps in full; read those pages rather than relying on a summary here.
Naming matters here. The Stream sample code checks a specific entitlement identifier, so if you follow that codebase, create the entitlement with the identifier "blue" to match. If you choose a different identifier, you must change every place the code reads that key — the customer-info check and the post-purchase check both reference it.
The entitlement is the stable concept your app asks about. Products and packages can change; the entitlement identifier is what the paywall and feature gate should depend on.
Stage 5: Add the SDK through Tuist
The Stream project integrates the subscription SDK as a Swift package managed by Tuist, which is not the path covered in the platform's standard installation documentation. The flow is:
- Declare the subscription SDK package in the Tuist dependencies file, alongside the other remote packages.
- Attach the external subscription SDK dependency to the target that needs it — in the sample, the profile target.
- Run
tuist fetchto resolve dependencies. - Run
tuist generateto regenerate the Xcode project.
The dependency declaration and target wiring are shown in the accompanying code modules; use those exact snippets rather than retyping the package coordinates. If you are not using Tuist, follow the platform's official iOS SDK installation and configuration guides instead and skip this stage's tooling steps.
Reading subscription state and offerings
The sample view model does three things. It builds a configuration with the public API key from your platform project settings and the current user ID, then calls Purchases.configure — the shared Purchases instance is configured during app launch. It fetches customer info and sets a boolean from whether the entitlement is active. It fetches offerings so the paywall can display what is for sale.
The entitlement check is the gate: the app treats the user as subscribed only when the entitlement's isActive value is true. The offerings call supplies the products to render. If offerings come back empty, the paywall has nothing to show even though the entitlement logic is fine — that is a catalog/configuration problem, not a purchase problem.
A quick field map for this stage:
- Public API key → from platform project settings, passed into the SDK configuration.
- App user ID → identifies whose customer info is being read.
- Entitlement identifier → the key looked up in the customer info entitlements.
- Offerings → the current catalog of packages the paywall can display.
Building the paywall and purchase button
The paywall view takes a Package as an input. A package belongs to an offering and groups equivalent products across platforms; in a single-platform iOS build it contains only iOS products.
The purchase button calls the SDK's purchase method with that package and inspects the returned customer info. If the entitlement is active after the transaction, the app can treat the purchase as complete. The sample paywall labels the button with a price string; in your own app, render the price from the package's store product rather than hard-coding a number, so the displayed price always matches the store configuration.
The settings screen ties it together: when the subscription is active it shows a subscribed confirmation; otherwise it iterates the current offering's available packages and presents the paywall for each.
Setup checklist and failure distinctions
Before you test a purchase, confirm each row:
- App Store Connect subscription exists and is in a state that allows testing.
- Its product ID is recorded and matches the platform product exactly.
- The platform product is attached to the entitlement your code reads.
- The entitlement identifier in code matches the one in the dashboard.
- The public API key in the app matches the project that owns the product.
- The SDK is linked to the target that runs the paywall, and the project was regenerated after adding it.
Two failures look similar but have different causes. If a purchase completes and no error appears but the entitlement stays inactive, check that the purchased product is attached to the entitlement and that the code reads the same identifier. If the paywall is empty, check that the current offering has packages and that the products are available — the entitlement check is not involved at that point.
Where to go next
The Stream tutorial series includes a wrap-up that closes out the full app build. If you want to compare subscription approaches, there are companion walkthroughs for StoreKit 2 in SwiftUI, Android in-app subscriptions, and React Native purchases with Expo. Each covers the same core ideas — product definition, entitlement state, and a purchase call — against a different platform's tooling.
Frequently asked questions
Does the entitlement identifier have to be "blue"?
Only if you are following the Stream sample code as written. The code looks up the entitlement by that key, so a different identifier works provided you update every lookup in the app to match the identifier you created in the dashboard.
Why does the paywall show nothing after setup?
The paywall renders packages from the current offering. An empty result usually means the offering has no available packages or the products are not available for the app configuration — check the offering and product setup before investigating the purchase flow.
Can I install the SDK without Tuist?
Yes. Tuist is only the integration route used by the Stream project. The platform's official iOS installation and SDK configuration guides cover other dependency managers and manual setup.
What does the purchase call return?
The purchase method returns a transaction, updated customer info, an error, and a user-cancelled flag. The sample checks the entitlement on the returned customer info to decide whether the subscription is active.
Should the price be hard-coded in the button label?
No. The sample displays a fixed price string, but in production you should render the price from the package's store product so the label reflects the actual store configuration.