Skip to main content
Complete technical documentation: See /docs/modules/Feature.Settings.md in the project

Purpose

FeatureSettings module handles:
  • Settings UI - User preferences management
  • Paywall - Beautiful subscription screen
  • Theme Selection - 5 built-in themes
  • Privacy Controls - Diagnostics, notifications
  • Account Management - Sign out, delete account

Key Components

SettingsViewModel

Manages app-wide settings:
@MainActor
@Observable
class SettingsViewModel {
    var currentTheme: UserThemePreference
    var shareDiagnostics: Bool
    var notificationsEnabled: Bool
    var isSubscribed: Bool
    
    func updateTheme(_ theme: UserThemePreference) async
    func toggleDiagnostics(_ enabled: Bool) async
    func signOut() async
}

PaywallViewModel

Manages subscription purchases:
@MainActor
@Observable
class PaywallViewModel {
    var offerings: [PaymentsOffering]
    var isLoading: Bool
    var error: String?
    
    func purchase(productID: String) async
    func restorePurchases() async
}

Settings Categories

Theme Selection:
  • System (follows iOS)
  • Light (always light)
  • Dark (always dark)
  • Aurora (teal/purple)
  • Obsidian (charcoal/amber)
Changes apply instantly!
User Controls:
  • Share diagnostics (opt-in crash reporting)
  • Notification permissions
  • Data export (GDPR)
  • Account deletion
Management:
  • Subscription status
  • Manage subscription (App Store)
  • Sign out
  • Delete account

Paywall UI

Beautiful subscription screen with:
  • ✅ Feature comparison
  • ✅ Pricing display
  • ✅ Monthly and annual options
  • ✅ Clear CTAs
  • ✅ Terms and privacy links
  • ✅ Restore purchases button

Customization Examples

Add New Setting

// 1. Add to Settings model
@Model
class Settings {
    var theme: UserThemePreference
    var shareDiagnostics: Bool
    var autoSaveChats: Bool  // New setting
}

// 2. Add to ViewModel
@Observable
class SettingsViewModel {
    var autoSaveChats: Bool
    
    func toggleAutoSave(_ enabled: Bool) async {
        autoSaveChats = enabled
        await settingsRepository.update(autoSaveChats: enabled)
    }
}

// 3. Add to UI
Toggle("Auto-save Chats", isOn: $viewModel.autoSaveChats)
    .onChange(of: viewModel.autoSaveChats) {
        Task { await viewModel.toggleAutoSave($0) }
    }

Customize Paywall

// In PaywallView, modify features list:
let proFeatures = [
    "Unlimited AI messages",
    "Access to GPT-4 and Claude",
    "Priority support",
    "Early access to features",
    "Custom AI personas"  // Add your feature
]

Add Custom Theme

// 1. Add color set in DesignSystemColors.xcassets
// 2. Add case to UserThemePreference
public enum UserThemePreference: String, Codable {
    case system, light, dark, aurora, obsidian
    case custom  // New theme
}

// 3. Update DSColors to map your theme
// 4. Add to theme picker in Settings

Paywall Best Practices

1

Clear Value

Show exactly what users get:
  • List specific features
  • Highlight most popular plan
  • Show savings (annual vs monthly)
2

Easy Purchase

  • Prominent CTAs
  • Clear pricing
  • Both monthly and annual
  • Restore purchases visible
3

Transparent Terms

  • Link to subscription terms
  • Link to privacy policy
  • Cancellation policy clear
  • Auto-renewal explained
4

Handle Errors

  • Purchase cancelled (don’t error)
  • Network failures (retry)
  • Already subscribed (show status)
  • Restore failures (help user)

Key Files

ComponentLocation
ViewModelsPackages/FeatureSettings/Sources/FeatureSettings/ViewModels/
Settings UIPackages/FeatureSettings/Sources/FeatureSettings/Views/SettingsView.swift
Paywall UIPackages/FeatureSettings/Sources/FeatureSettings/Views/PaywallView.swift

Dependencies

  • Core - Error handling, logging, theme types
  • Payments - Subscription management
  • DesignSystem - UI components

Used By

  • Main App - Settings tab
  • All features - Theme observation
  • Profile - Subscription status

Best Practices

  • Save immediately on change
  • Use repository pattern
  • Handle errors gracefully
  • Provide feedback
  • Make it beautiful
  • Highlight value
  • Easy to dismiss
  • Test purchase flow
  • Opt-in for tracking
  • Clear data policies
  • Easy account deletion
  • GDPR compliance

Learn More

Build with AI (fast)

You can customize this module in minutes using our ready-to-paste LLM prompts.

Example Prompt

Context: SwiftAIBoilerplatePro/AppShell/Onboarding* Prompt: “Add a Privacy step to onboarding that links to the policy page and a ‘Continue’ CTA.” See all prompts → /docs/prompts/OnboardingModule.prompts.md
See in project: docs/modules/OnboardingModule.md

Test Coverage

75%+ - Settings and paywall testing Tests include:
  • Settings persistence
  • Theme switching
  • Paywall display
  • Purchase flows
  • Error handling
I