getting-started

작성자: facebook

SDK setup, Swift Package Manager integration, Info.plist configuration, and first connection to Meta glasses

npx skills add https://github.com/facebook/meta-wearables-dat-ios --skill getting-started

Getting Started with DAT SDK (iOS)

Set up the Meta Wearables Device Access Toolkit in an iOS app.

Prerequisites

  • Xcode 15.0+, iOS 16.0+ deployment target
  • Meta AI companion app installed on test device
  • Ray-Ban Meta glasses or Meta Ray-Ban Display glasses (or use MockDeviceKit for development)
  • Developer Mode enabled in Meta AI app (Settings > Your glasses > Developer Mode)

Step 1: Add the SDK via Swift Package Manager

  1. In Xcode, select File > Add Package Dependencies...
  2. Enter https://github.com/facebook/meta-wearables-dat-ios
  3. Select a version
  4. Add MWDATCore and MWDATCamera to your target

Step 2: Configure Info.plist

Add these required entries to your Info.plist:

<!-- URL scheme for Meta AI callbacks -->
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLName</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>myexampleapp</string>
    </array>
  </dict>
</array>

<!-- External accessory protocol -->
<key>UISupportedExternalAccessoryProtocols</key>
<array>
  <string>com.meta.ar.wearable</string>
</array>

<!-- Background modes -->
<key>UIBackgroundModes</key>
<array>
  <string>bluetooth-peripheral</string>
  <string>external-accessory</string>
</array>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Needed to connect to Meta Wearables</string>

<!-- DAT configuration -->
<key>MWDAT</key>
<dict>
  <key>AppLinkURLScheme</key>
  <string>myexampleapp://</string>
  <key>MetaAppID</key>
  <string>0</string>
</dict>

Replace myexampleapp with your app's URL scheme. Use 0 for MetaAppID during development with Developer Mode. Also add fb-viewapp to the Info.plist URL query-schemes allowlist used by UIApplication.canOpenURL so the SDK can detect and open Meta AI.

Step 3: Initialize the SDK

Call Wearables.configure() once at app launch:

import MWDATCore

@main
struct MyApp: App {
    init() {
        do {
            try Wearables.configure()
        } catch {
            assertionFailure("Failed to configure Wearables SDK: \(error)")
        }
    }

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

Step 4: Handle URL callbacks

Your app must handle the URL callback from Meta AI after registration:

.onOpenURL { url in
    Task {
        _ = try? await Wearables.shared.handleUrl(url)
    }
}

Step 5: Register with Meta AI

func startRegistration() async throws {
    try await Wearables.shared.startRegistration()
}

Observe registration state:

Task {
    for await state in Wearables.shared.registrationStateStream() {
        // Update UI based on registration state
    }
}

Step 6: Start streaming

import MWDATCore
import MWDATCamera

// Create a DeviceSession — device selection is configured here
let wearables = Wearables.shared
let deviceSelector = AutoDeviceSelector(wearables: wearables)
let deviceSession = try wearables.createSession(deviceSelector: deviceSelector)
try deviceSession.start()

// Wait for the device session to reach the started state
for await state in deviceSession.stateStream() {
    if state == .started { break }
}

let config = StreamConfiguration(
    videoCodec: .raw,
    resolution: .low,
    frameRate: 24
)
guard let camera = try deviceSession.addCamera(config: config) else {
    return
}
let stream = camera.stream

// Observe frames
let frameToken = stream.videoFramePublisher.listen { frame in
    guard let image = frame.makeUIImage() else { return }
    Task { @MainActor in
        self.currentFrame = image
    }
}

// Start the stream capability
stream.start()

Next steps

facebook의 다른 스킬

api-health
facebook
Monitor API health for a Meta app — check rate limits, call volume, and API deprecations. Use to diagnose throttling, plan capacity, or prepare for API version…
official
api-integration
facebook
Guide a developer through setting up a Meta API integration from scratch — discovers the right APIs, fetches setup guides, authentication requirements,…
official
app-review-prep
facebook
Prepare a Meta app for App Review — checks current status, outstanding requirements, granted privileges, and submission history. Use before submitting an app…
official
debug-webhooks
facebook
Meta 앱의 웹훅 문제를 해결합니다 — 활성 구독을 검사하고, 잘못된 구성을 식별하며, 테스트 페이로드를 전송하여 전달을 확인합니다. 다음과 같은 경우에 사용하세요…
official
webhook-setup
facebook
Set up webhooks for a Meta app end-to-end — discover available topics, subscribe to fields, and verify with a test payload. Use when configuring webhooks for…
official
buck2-rule-basics
facebook
Guide users through writing their first Buck2 rule to learn fundamental concepts including rules, actions, targets, configurations, analysis, and select(). Use…
official
add-ir-instruction
facebook
Guide for adding a new IR instruction to the Hermes compiler. Use when the user asks to add, create, or define a new IR instruction (Inst/Instruction) in the…
official
binary-size-analysis
facebook
이 스킬은 사용자가 일련의 커밋 범위에서 hermesvm 바이너리 크기 변경을 분석하려 할 때 사용해야 합니다. 사용자가 "바이너리 크기"를 언급할 때 사용하세요.
official