Skip to content
imaged
Docs / Setup / Swift

Swift setup.

Drop imaged.xcframework into your macOS or iOS target, import imaged, ship.

Prerequisites
Xcode 15.0 or later
macOS Sonoma 14.0+, Apple Silicon
iOS 15.0+ on device, simulator slice included
Apple Developer team Required for the hardened runtime to load the framework
License token JWT issued from /dashboard
  1. 01

    Download the framework

    Pull the right zip from the downloads page. macOS ships inside imaged-macos-arm64-0.10.0.tar.gz; iOS ships as imaged.xcframework-ios.zip. Both expose the same Swift module.

    bash
    unzip imaged.xcframework-ios.zip
    # or extract from macOS tarball:
    tar -xzf imaged-macos-arm64-0.10.0.tar.gz
  2. 02

    Embed in Xcode

    Drag imaged.xcframework into the project navigator. In the target's General tab, under Frameworks, Libraries, and Embedded Content, set it to Embed & Sign. Without that flag, you get "Library not loaded" at launch.

  3. 03

    Hello world

    Construct AISDK, paste the license token from /dashboard, verify it, read the version. checkLicense returns 200 on success; the same status codes appear in every binding.

    swift
    import SwiftUI
    import imaged
    
    struct ContentView: View {
        @State private var ai = AISDK()
        @State private var status = "Initializing..."
    
        var body: some View {
            VStack(alignment: .leading, spacing: 8) {
                Text("imaged \(ai.version)").font(.title)
                Text(status)
            }
            .padding()
            .onAppear { configure() }
        }
    
        private func configure() {
            let cfg = ai.options
            cfg.setOption(forKey: "license.token", stringValue: "your-license-token")
            cfg.setOption(forKey: "license.audience", stringValue: "cameras.acme.com")
            let result = cfg.checkLicense()
            status = (result == .success && ai.isLicensed)
                ? "Licensed"
                : "License invalid (status \(result.rawValue))"
        }
    }
  4. 04

    Build and run

    Press Run in Xcode. The console prints "imaged 0.10.0" and the view shows "Licensed". A status of 204 means the token key was missing; 205 means signature verification failed.

  5. 05

    Run a family

    Bundle the model file in your target, set yolo.model to its bundle path, and call ai.detect("yolo", in: image). The full pattern lives in CameraDetector.swift in the example repo.

    swift
    let img = AIImage()
    img.load(from: "bus.jpg")
    
    cfg.setOption(forKey: "yolo.model",
                  stringValue: Bundle.main.path(forResource: "yolo26x", ofType: "onnx")!)
    let response = ai.detect("yolo", in: img)
    for obj in response.objects ?? [] {
        print(obj.label ?? "?", obj.score)
    }
  6. 06

    Where to go next

    The macOS tutorial in the examples repo walks through the same steps with screenshots and troubleshooting. The iOS app adds AVFoundation and a live overlay.