Skip to main content

Documentation Index

Fetch the complete documentation index at: https://muchadostudio.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

The Swift SDK requires iOS 17.0+ and is built with SwiftUI for modern iOS apps.

Installation

Swift Package Manager

Add the package dependency in Xcode:
  1. File → Add Package Dependencies
  2. Enter: https://github.com/tom-muchadostudio/onboardsync_ios.git
  3. Select version 1.1.1 or later and add to your target

Setup

Info.plist Configuration

Add required permissions based on your onboarding flow:
<!-- Camera permission -->
<key>NSCameraUsageDescription</key>
<string>This app needs camera access for profile photos</string>

<!-- Photo library permission -->
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs photo library access to select images</string>

<!-- Location permission -->
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs location access to provide local features</string>

<!-- Face ID permission (if using biometric authentication) -->
<key>NSFaceIDUsageDescription</key>
<string>This app uses Face ID for secure authentication</string>

Basic Usage

import SwiftUI
import OnboardSync

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

struct ContentView: View {
    @State private var showingOnboarding = true
    
    var body: some View {
        VStack {
            Text("Your main app content")
        }
        .onAppear {
            showOnboarding()
        }
    }
    
    func showOnboarding() {
        let config = OnboardSyncConfig(
            projectId: "your-project-id",
            secretKey: "your-secret-key", // Get from dashboard
            testingEnabled: true, // Optional, shows onboarding every time
            onComplete: { result in
                // Access form responses if available
                if let result = result, result.hasResponses {
                    for response in result.responses {
                        print("\(response.questionText): \(response.answerAsString ?? "")")
                    }
                }
            }
        )
        
        OnboardSync.showOnboarding(config: config)
    }
}

UIKit

import UIKit
import OnboardSync

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        showOnboarding()
    }
    
    func showOnboarding() {
        let config = OnboardSyncConfig(
            projectId: "your-project-id",
            secretKey: "your-secret-key",
            onComplete: { result in
                // Access form responses
                if let result = result {
                    print("Got \(result.responseCount) responses")
                }
                self.navigateToMainApp()
            }
        )
        
        OnboardSync.showOnboarding(config: config)
    }
    
    func navigateToMainApp() {
        // Your navigation logic here
    }
}

Configuration Options

let config = OnboardSyncConfig(
    projectId: "your-project-id",
    secretKey: "your-secret-key",
    testingEnabled: true, // Optional, shows onboarding every time
    onComplete: { result in
        // Handle completion with form responses
        if let result = result {
            print("Got \(result.responseCount) responses")
        }
    }
)
projectId
String
required
Your project ID from the OnboardSync dashboard
secretKey
String
required
Your secret key from the OnboardSync dashboard (found in API Keys section)
testingEnabled
Bool
default:"false"
Enable testing mode to show onboarding every time (ignores completion status)
onComplete
(OnboardingResult?) -> Void
required
Callback closure called when onboarding completes, receives optional OnboardingResult with form responses

API Reference

OnboardSync.showOnboarding

static func showOnboarding(config: OnboardSyncConfig)
Static method for showing onboarding. The config includes all necessary parameters.

OnboardSyncConfig

struct OnboardSyncConfig {
    let projectId: String
    let secretKey: String
    let testingEnabled: Bool  // default: false
    let onComplete: ((OnboardingResult?) -> Void)?
}

OnboardingResult

Contains all form responses from a completed onboarding flow:
struct OnboardingResult {
    let flowId: String                    // The completed flow ID
    let responses: [OnboardingResponse]   // All form responses
    
    // Helper methods
    func getResponseByQuestion(_ questionText: String) -> OnboardingResponse?
    var textResponses: [OnboardingResponse]
    var singleChoiceResponses: [OnboardingResponse]
    var multipleChoiceResponses: [OnboardingResponse]
    var hasResponses: Bool
    var responseCount: Int
}

OnboardingResponse

A single question response:
struct OnboardingResponse {
    let questionText: String    // The question asked
    let questionType: String    // 'question_text', 'question_single_choice', or 'question_multiple_choice'
    let answer: OnboardingAnswer // String or [String]
    let screenId: String?       // Screen where question appeared
    
    var answerAsString: String? // Get answer as single string
    var answerAsList: [String]  // Get answer as list
}

Example: Accessing Form Responses

onComplete: { result in
    guard let result = result, result.hasResponses else { return }
    
    // Get specific response
    if let nameResponse = result.getResponseByQuestion("What's your name?") {
        print("Name: \(nameResponse.answerAsString ?? "")")
    }
    
    // Filter by type
    for textResponse in result.textResponses {
        print("\(textResponse.questionText): \(textResponse.answerAsString ?? "")")
    }
}

Advanced Usage

Permission Handling

The SDK automatically handles permission requests configured in your onboarding flow:
// Permissions are requested based on your flow configuration
// No additional code needed - the SDK handles:
// - Camera permission
// - Photo library permission  
// - Location permission
// - Notifications permission
// - App tracking transparency

Custom Styling

// The SDK respects your app's status bar style
OnboardSyncView(config: config)
    .preferredColorScheme(.dark) // Force dark mode
    .statusBar(hidden: false)

Testing & Development

For testing, you can reset the onboarding status:
import OnboardSync

// Clear stored completion status (for testing)
OnboardSync.resetForTesting()

Testing Mode

Enable testing mode to show onboarding every time:
let config = OnboardSyncConfig(
    projectId: "your-project-id",
    secretKey: "your-secret-key",
    testingEnabled: true // Shows onboarding every time for testing
)

Platform Requirements

  • iOS 17.0+
  • Swift 5.9+
  • Xcode 15.0+
  • SwiftUI for OnboardSyncView
  • UIKit support via static methods

Troubleshooting

  1. Verify your project ID and secret key are correct
  2. Check network connectivity
  3. Enable debug mode to see detailed errors
  4. Ensure the flow is published in the dashboard
Make sure you’ve added the required usage descriptions to Info.plist
Check that your domain is correct and the server is accessible
Ensure you’re using iOS 17.0+ and have imported the SDK correctly

Best Practices

  • Initialize OnboardSync early in app lifecycle
  • Handle all error cases gracefully
  • Test on various iOS versions (11.0+)
  • Use async/await for cleaner code
  • Implement proper loading states

Example App

Check out our iOS example app for a complete implementation.

Next Steps

SwiftUI Guide

Advanced SwiftUI integration

API Reference

Explore the REST API