SwiftUI UXCam package

📘

Note

All UXCam properties and methods are also available in UXCamSwiftUI without additional import of UXCam and can be accessed using UXCamCore. For eg. UXCam.isRecording() can be accessed into UXCamSwiftUI as UXCamCoreSwiftUI.isRecording()

pod version

SDK Integration

If you're building your app using SwiftUI, please integrate UXCam using Swift Package Manager or Cocoapods using the following steps:

Cocoapods

  • Add to the Podfile
pod 'UXCamSwiftUI'
  • Run pod install in the project directory to download dependency.

Swift Package Manager

Add UXCamSwiftUI Package:

https://github.com/uxcam/uxcam-ios-swiftui

Securely load your App Key

Where

How-To

Pros / Cons

Info.plist placeholder (recommended)

Add UXCamAppKey = $(UXCAM_APP_KEY) to Info.plist and define UXCAM_APP_KEY as a User‑Defined build setting (or in an ignored .xcconfig).

  • Keeps key out of source control
  • Simple to read at runtime

CI env var injection

Add UXCAM_APP_KEY to your CI secret store and pass -DUXCAM_APP_KEY=$(UXCAM_APP_KEY) to xcodebuild.

  • Zero key on developer laptops
  • Extra CI config

Runtime fetch (remote config)

Download the key from your config service before initialising UXCam.

  • Central rotation
  • Potential slight delay before first session
// Bundle-based lookup (works for techniques 1 & 2)\
let appKey = Bundle.main.object(forInfoDictionaryKey: "UXCamAppKey") as! String

Initialization Steps:

  • Import UXCam at the top of your main App struct:
import UXCamSwiftUI
  • Add an init method to your main App struct and add the following calls:
@main
struct MyApp: App {
    init() {
        // 1. Opt‑in for wireframe screenshots (App Store review safe)
        UXCamCore.optIntoSchematicRecordings()

        // 2. Build configuration
        var config = Configuration(appKey: appKey)
        config.enableAutomaticScreenNameTagging = true // default

        #if DEBUG
        // 🔍 Verbose integration logs only in Debug builds
        config.enableIntegrationLogging = true
        #endif

        // 3. Start UXCam
        UXCamSwiftUI.start(with: config)
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

WhereWhen to UseCode Snippet
SceneDelegate in mixed projectsYou migrated screen‑by‑screen and still have a SceneDelegate.Call the same init block in scene(_:willConnectTo:options:).
WidgetKit extensionRecord interactions inside a widget.Import UXCamSwiftUI in the widget’s @main and call UXCamSwiftUI.start in init().
Preview modeAvoid SDK traffic in SwiftUI previews.Guard with if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != "1".

👍

That completes the integration process.
Your session will be shown on the dashboard within a few seconds after the app goes in the background. You can optionally use the API's for customizations such as identifying users from your database with UXCam, tagging sessions or hiding sensitive views.

🚧

Warning

Screen Tagging and Hiding Sensitive Data for Swift UI have some differences and you can check some examples on the documentation, all other customization APIs provided by UXCam can be called regularly done with iOS by importing UXCam and calling the desired method.