Skip to content
Mobile
Skill

/sample-app-guide

Building a complete DAT app with camera streaming and photo capture

From plugin
meta-wearables-dat-ios
59518 skills

Claude Code

$ npx -y skills add meta/meta-wearables-dat-ios --skill sample-app-guide --agent claude-code

SKILL.md

sample-app-guide.SKILL.md
name: sample-app-guide
description: Building a complete DAT app with camera streaming and photo capture

Sample App Guide (iOS)

Build an iOS DAT app with camera streaming and photo capture.

This walkthrough covers app setup, registration, streaming, and capture. Pair it with the [CameraAccess sample](https://github.com/meta/meta-wearables-dat-ios/tree/main/samples).

Project setup

1. Create a new Xcode project (SwiftUI App) 2. Add the SDK via SPM: `https://github.com/meta/meta-wearables-dat-ios` 3. Add `MWDATCore`, `MWDATCamera`, and `MWDATMockDevice` to your target 4. Configure `Info.plist` and add the Hotspot Configuration capability (see [Getting Started](getting-started.md))

App architecture

A typical DAT app has these components:

MyDATApp/
├── MyDATApp.swift              # App entry point, SDK init
├── ViewModels/
│   ├── WearablesViewModel.swift    # Registration, device management
│   └── StreamViewModel.swift # Streaming, photo capture
└── Views/
    ├── MainAppView.swift           # Navigation
    ├── RegistrationView.swift      # Registration UI
    └── StreamView.swift            # Video preview, capture button

SDK initialization

import MWDATCore

@main
struct MyDATApp: App {
    init() {
        do {
            try Wearables.configure()
        } catch {
            assertionFailure("Wearables SDK configuration failed: \(error)")
        }
    }

    var body: some Scene {
        WindowGroup {
            MainAppView()
                .onOpenURL { url in
                    guard
                        let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
                        components.queryItems?.contains(where: { $0.name == "metaWearablesAction" }) == true
                    else {
                        return
                    }
                    Task {
                        _ = try? await Wearables.shared.handleUrl(url)
                    }
                }
        }
    }
}

Wearables ViewModel

`devicesStream()` yields `[DeviceIdentifier]` (a `[String]`), not device objects. Resolve each identifier with `wearables.deviceForIdentifier(_:)` when you need `nameOrId()`, `deviceType()`, `linkState`, or `compatibility()`.

import MWDATCore

@MainActor
class WearablesViewModel: ObservableObject {
    @Published var registrationState: RegistrationState
    @Published var devices: [DeviceIdentifier] = []

    private let wearables = Wearables.shared

    init() {
        registrationState = Wearables.shared.registrationState
    }

    func observeState() {
        Task {
            for await state in wearables.registrationStateStream() {
                self.registrationState = state
            }
        }
        Task {
            for await deviceIds in wearables.devicesStream() {
                self.devices = deviceIds
            }
        }
    }

    func register() async {
        try? await wearables.startRegistration()
    }

    func unregister() async {
        try? await wearables.startUnregistration()
    }
}

Stream ViewModel

import Combine
import MWDATCamera
import MWDATCore
import UIKit

@MainActor
class StreamViewModel: ObservableObject {
    @Published var currentFrame: UIImage?
    @Published var streamState: String = "Stopped"
    @Published var capturedPhoto: Data?

    private let wearables = Wearables.shared
    private var deviceSession: DeviceSession?
    private var camera: Camera?
    private var stream: MWDATCamera.Stream?
    private let streamTokens = ListenerTokenBag()

    func startStream() async {
        let config = StreamConfiguration(
            videoCodec: .raw,
            resolution: .medium,
            frameRate: 24
        )
        let selector = AutoDeviceSelector(wearables: wearables)

        do {
            let deviceSession = try wearables.createSession(deviceSelector: selector)
            let states = deviceSession.stateStream()
            try deviceSession.start()
            // Wait for the device session to reach the started state
            for await state in states {
                if state == .started { break }
            }
            guard let camera = try deviceSession.addCamera(config: config) else { return }
            self.deviceSession = deviceSession
            self.camera = camera
            self.stream = camera.stream
        } catch {
            return
        }

        guard let stream else { return }

        stream.statePublisher.listen { [weak self] state in
            Task { @MainActor in
                self?.streamState = "\(state)"
            }
        }.store(in: streamTokens)

        stream.videoFramePublisher.listen { [weak self] frame in
            guard let image = frame.makeUIImage() else { return }
            Task { @MainActor in
                self?.currentFrame = image
            }
        }.store(in: streamTokens)

        stream.photoDataPublisher.listen { [weak self] photoData in
            Task { @MainActor in
                self?.capturedPhoto = photoData.data
            }
        }.store(in: streamTokens)

        stream.start()
    }

    func stopStream() {
        streamTokens.clear()
        // Stopping the camera cascades to its stream child
        camera?.stop()
        deviceSession?.stop()
        stream = nil
        camera = nil
        deviceSession = nil
        // Cleared listeners won't see .stopped, so set the state here
        streamState = "Stopped"
    }

    func capturePhoto() {
        stream?.capturePhoto(format: .jpeg)
    }
}

Behaviors the CameraAccess sample also covers

  • **Two explicit steps.** "Start Session" creates and starts the `DeviceSession`; "Preview" adds the `Camera` and starts the stream. Stopping the preview leaves the session connected so the user can start it again without re-creating the session.
  • **Bind the UI to the SDK's own states.** Mirror `DeviceSessionState` and `StreamState` instead of m
Read more
@facebook
Ships withmeta-wearables-dat-ios

The Meta Wearables Device Access Toolkit enables developers to utilize Meta's AI glasses to build hands-free wearable experiences into their mobile applications.

Stars on GitHub

Momentum

stars in total
595
Star history of facebook/meta-wearables-dat-ios on GitHub, a chart by star-history.com

Other skills on meta-wearables-dat-ios.

More skills from other plugins.

deep-code-review

deep-code-review

In-depth design-focused code review - understands codebase context before evaluating PR changes, posts structured feedback to…

expo13d53k
@expo@expoInstall Skill
modlens

modlens

Plug-in vision for text-only models. Hard rule: when a file path or URL with an image extension (.png, .jpg, .jpeg, .webp, .gif,…

modlens4w4.6k
@liustack@liustackInstall Skill
appllama-app-design-skill

appllama-app-design-sk…

Build native-feeling, benchmark-quality mobile app screens (Expo / React Native). Use when designing or implementing any mobile…

appllama2mo3.9k
@appllama@appllamaInstall Skill

Questions about sample-app-guide.

Which coding agents can use sample-app-guide?
sample-app-guide installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.