Help us improve
Share bugs, ideas, or general feedback.
How this skill is triggered — by the user, by Claude, or both
Slash command
/mwdat-ios:sample-app-guideThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Build an iOS DAT app with camera streaming and photo capture.
Guides building an Android DAT app with registration, camera sessions, streaming, and photo capture using Meta Wearables SDK.
Guides through SDK setup, Swift Package Manager integration, Info.plist configuration, and first connection to Meta glasses for iOS apps.
Supports iOS app development: writes Swift/SwiftUI/UIKit code, architects apps, debugs crashes, handles navigation/networking/persistence/animations/performance, configures Xcode/App Store.
Share bugs, ideas, or general feedback.
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/facebook/meta-wearables-dat-iosMWDATCore, MWDATCamera, and MWDATMockDevice to your targetInfo.plist (see Getting Started)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
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
Task {
_ = try? await Wearables.shared.handleUrl(url)
}
}
}
}
}
import MWDATCore
@MainActor
class WearablesViewModel: ObservableObject {
@Published var registrationState: String = "Unknown"
@Published var devices: [DeviceIdentifier] = []
private let wearables = Wearables.shared
func observeState() {
Task {
for await state in wearables.registrationStateStream() {
self.registrationState = "\(state)"
}
}
Task {
for await devices in wearables.devicesStream() {
self.devices = devices.map { $0.identifier }
}
}
}
func register() async {
try? await wearables.startRegistration()
}
func unregister() async {
try? await wearables.startUnregistration()
}
}
import MWDATCamera
import MWDATCore
@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 stream: Stream?
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)
try deviceSession.start()
// Wait for the device session to reach the started state
for await state in deviceSession.stateStream() {
if state == .started { break }
}
guard let stream = try deviceSession.addStream(config: config) else { return }
self.deviceSession = deviceSession
self.stream = stream
} catch {
return
}
guard let stream else { return }
_ = stream.statePublisher.listen { [weak self] state in
Task { @MainActor in
self?.streamState = "\(state)"
}
}
_ = stream.videoFramePublisher.listen { [weak self] frame in
guard let image = frame.makeUIImage() else { return }
Task { @MainActor in
self?.currentFrame = image
}
}
_ = stream.photoDataPublisher.listen { [weak self] photoData in
Task { @MainActor in
self?.capturedPhoto = photoData.data
}
}
await stream.start()
}
func stopStream() {
Task { await stream?.stop() }
deviceSession?.stop()
stream = nil
deviceSession = nil
}
func capturePhoto() {
stream?.capturePhoto(format: .jpeg)
}
}
Add mock device support to develop without glasses:
import MWDATMockDevice
func setupMockDevice() async {
let mockDeviceKit = MockDeviceKit.shared
mockDeviceKit.enable()
let device = mockDeviceKit.pairRaybanMeta()
device.don()
if let videoURL = Bundle.main.url(forResource: "test_video", withExtension: "mov") {
let camera = device.services.camera
camera.setCameraFeed(fileURL: videoURL)
}
}
func tearDownMockDevice() {
MockDeviceKit.shared.disable()
}
Your DAT app should only depend on:
MWDATCore — always requiredMWDATCamera — for camera streamingMWDATMockDevice — for testing (can be test-only dependency)