The iOS SDK is a Swift library for iPhone apps. It fetches your workspace's published face lenses and screen effects with an API key, checks every file, keeps each version on the phone, and draws them in your app. It follows the same format and drawing rules as the studio's live preview, so it draws what your designers see in the editor.
The current version is 0.4.0. It is published as a binary, with a sample app, at github.com/Ingevora/mirage-ios.
In Xcode, choose File → Add Package Dependencies…, enter https://github.com/Ingevora/mirage-ios, and choose the exact version 0.4.0. Or add it to Package.swift:
https://github.com/Ingevora/mirage-ios
Package.swift
.package(url: "https://github.com/Ingevora/mirage-ios.git", exact: "0.4.0"),
and the product, for your target:
.product(name: "IngevoraMirage", package: "mirage-ios"),
Make one client for the app, with the app's API key, and keep it.
import IngevoraMirage let mirage = MirageClient(configuration: .init(apiKey: "mk_…")) // Prefetch what the app will show, so it starts without waiting. let effect = try await mirage.prefetchEffect(id: "7c1e9a2b-4d3f-4a6e-8b5c-2f9d0e1a3b4c")
async
prefetchLens(id:version:)
prefetchEffect(id:version:)
version
// One player per screen that shows effects; keep it, for example in the screen's view model. let player = MirageEffectPlayer(mirage: mirage) // SwiftUI: an overlay above the screen's content. It passes every touch through. content.overlay { MirageEffectOverlay(player: player).ignoresSafeArea() } // UIKit: add MirageEffectView(player: player) above the content, pinned to the screen's edges. player.play(effectId: "7c1e9a2b-4d3f-4a6e-8b5c-2f9d0e1a3b4c") player.onEnd = { playback in if playback.state == .ended(.finished) { // the effect finished } }
player.cue(effectId:)
Codable
player.play(cue)
// One player per camera session; keep it. let lens = MirageLensPlayer(mirage: mirage) lens.attach(lensId: "3f2b8c1e-6d4a-4f7e-9b2c-8a1d5e6f7a90") // stored at once, else downloaded // On your video queue, for every camera frame: send it, and show the frame that comes back. let drawn = lens.process(pixelBuffer, time: presentationTime, orientation: .right) // The self-view, in SwiftUI; MirageLensPreviewView(player: lens) in UIKit. MirageLensPreview(player: lens)
process
.right
process(_:time:orientation:face:)
state
Your app sends its own event names, and the triggers that listen for them run:
player.fire(event: "order.placed") // every running screen effect lens.fire(event: "round.start") // the attached face lens
A name the format doesn't allow is ignored. See Triggers and your events.
A failure is a MirageError:
MirageError
invalidAPIKey
401
productDisabled
403
notFound
404
unavailable
429
5xx
engineTooOld
unsupportedFormat
invalidPackage
A later version may add cases to the SDK's enums, so a switch over one needs @unknown default:
switch
@unknown default
switch error { case .invalidAPIKey: showKeyHelp() case .notFound: showMissing() default: showRetry() // or list every case, then `@unknown default:` }
See Errors and limits.
Library/Caches/com.ingevora.mirage
clearCache()
freshness
source
.cacheFallback
The SDK plays published face lenses and screen effects only. To try a draft face lens before you publish it, use Test on your phone: its QR code opens the draft on your phone's camera, in the browser.
If you build the SDK from source in a debug build, player.play(testLink:) also plays a screen effect's test link from Test on your phone. The release package has no test links.
player.play(testLink:)
The framework carries a privacy manifest (PrivacyInfo.xcprivacy): the SDK collects no data, does no tracking, and uses none of the APIs Apple asks a reason for. Camera frames never leave the phone.
PrivacyInfo.xcprivacy
Example/MirageExample.xcodeproj in the repository shows the whole integration in four short files. Open it, choose your team and a bundle ID of your own (the target's Signing & Capabilities), and run it on an iPhone. Paste your API key, then the id of a published face lens or screen effect.
Example/MirageExample.xcodeproj