SwiftUI prototype that demonstrates an onboarding → paywall → main flow with a mocked billing service. The project is intentionally small, so you can review state propagation, MVVM layers, and async payment handling without touching a real StoreKit integration.
- SwiftUI-only UI with onboarding pager, plan selector, and placeholder main view.
AppFlowViewModeldrives the navigation flow (hasFinishedOnboarding,hasSubscription) and persists purchase status with@AppStorage.PaywallViewModelwraps subscription plans, selected plan state, mock billing (SubscriptionPaymentServicing), and exposes purchase status for the UI toast.- Async/await based mock billing service (
MockSubscriptionPaymentService) that simulates network delay, random errors, and returns fake transaction metadata. PurchaseStatusViewrenders a bottom toast showing processing/success/failure with auto-dismiss timers.
SubscriptionDemoApplaunchesRootView.RootViewinjects three@StateObjects (flow, onboarding, paywall view models) and conditionally renders:OnboardingViewuntil the onboarding flag flips.PayWallViewuntil a mock purchase succeeds.MainViewafterwards.
- Child views communicate via closures (
onFinish,onPurchase) and view model updates bubble through@Publishedto swap screens. PayWallViewcallspaywallViewModel.purchaseSelectedPlan()inside aTask, shows a spinner on the button, and rendersPurchaseStatusViewoverlays based onpurchaseStatus.
SubscriptionDemo/
├── AppFlowViewModel.swift
├── OnboardingView.swift / OnboardingViewModel.swift
├── PayWallView.swift
├── PaywallViewModel.swift
├── PurchaseStatusView.swift
├── SubscriptionPaymentService.swift
├── MainView.swift
├── RootView.swift
└── Assets.xcassets
- Requirements: macOS with Xcode 16.4+ and Swift 5.9+.
- Open
SubscriptionDemo.xcodeproj. - Select the
SubscriptionDemoscheme and run on an iOS simulator/device. - Tap through onboarding, hit “Continue” on the paywall (mock payment), and observe the status toast.
- Replace the mock service by implementing
SubscriptionPaymentServicingwith StoreKit 2. - Add persistence for onboarding progress, multi-tier plans, or promotional pricing.
- Extend UI tests or snapshot tests for the paywall and status toast.


