dat-conventions

bởi facebook

Các mẫu Swift, async/await, quy ước đặt tên, các kiểu chính cho phát triển DAT SDK iOS

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

DAT SDK Conventions (iOS)

Architecture

The SDK is organized into four modules:

  • MWDATCore: Device discovery, registration, permissions, device selectors
  • MWDATCamera: Stream, VideoFrame, photo capture
  • MWDATDisplay: Display capability, display UI components, icons, images, buttons, video
  • MWDATMockDevice: MockDeviceKit for testing without hardware

Swift Patterns

  • Use async/await for all SDK operations — the SDK is fully async
  • Use AsyncSequence / publisher .listen {} for observing streams
  • Annotate UI-updating code with @MainActor
  • Never block the main thread with frame processing
  • Handle errors with do/catch — the SDK throws typed errors

Naming Conventions

TypeConventionExample
Entry pointWearables.sharedWearables.shared.startRegistration()
Device sessions*SessionDeviceSession
CapabilitiesNamed by functionStream
Selectors*DeviceSelectorAutoDeviceSelector, SpecificDeviceSelector
Config*ConfigurationStreamConfiguration
Publishers*PublisherstatePublisher, videoFramePublisher

Imports

import MWDATCore    // Registration, devices, permissions
import MWDATCamera  // Stream, VideoFrame, photo capture
import MWDATDisplay // Display, FlexBox, Text, Button, Image, Icon, VideoPlayer

For testing:

import MWDATMockDevice  // MockDeviceKit, MockGlasses, MockCameraKit

Key Types

  • Wearables — SDK entry point. Call Wearables.configure() at launch, then use Wearables.shared
  • Stream — Camera streaming session. Create with config + device selector
  • Display — Display capability attached to a started DeviceSession
  • VideoFrame — Individual video frame with .makeUIImage() convenience
  • AutoDeviceSelector — Automatically selects the best available device
  • SpecificDeviceSelector — Selects a specific device by identifier
  • StreamConfiguration — Configure video codec, resolution, frame rate
  • MockDeviceKit — Factory for creating simulated devices in tests

Error Handling

do {
    try Wearables.configure()
} catch {
    // Handle configuration error
}

do {
    try await Wearables.shared.startRegistration()
} catch {
    // Handle registration error
}

Build and Test

# Install dependencies via Swift Package Manager
# In Xcode: File > Add Package Dependencies > enter repo URL

# Build from command line
xcodebuild -scheme MWDATCore -destination 'platform=iOS Simulator,name=iPhone 16'

# Run tests
xcodebuild test -scheme MWDATCoreTests -destination 'platform=iOS Simulator,name=iPhone 16'

For sample apps:

# Open the sample app workspace
open ExternalSampleApps/CameraAccess/CameraAccess.xcodeproj

# Build and run on simulator (uses MockDeviceKit - no glasses needed)
xcodebuild -scheme CameraAccess -destination 'platform=iOS Simulator,name=iPhone 16'

Development Workflow

  1. Add SDK via Swift Package Manager (SPM) in Xcode
  2. Import modules (MWDATCore, MWDATCamera, MWDATDisplay when rendering Display content)
  3. Configure at app launch: try Wearables.configure()
  4. Build with Xcode or xcodebuild
  5. Test with MockDeviceKit - no physical glasses required
  6. Debug using Xcode console for SDK logs

Live docs search

If your editor supports remote MCP servers, connect https://mcp.developer.meta.com/wearables and use search_dat_docs for current DAT setup, session lifecycle, camera streaming, MockDeviceKit, permissions, and exact API symbols. This public docs server does not require authentication; do not configure tokens, OAuth, or custom authorization headers for it.

Use llms.txt when your tool only supports static reference context.

Links

Thêm skills từ facebook

binary-size-analysis
facebook
Phân tích thay đổi kích thước tệp nhị phân theo từng commit của thư viện dùng chung hermesvm trong một phạm vi commit git. Tạo báo cáo markdown với kích thước theo từng commit và bảng tóm tắt các mức tăng giảm đáng kể.
official
modify-jsi-features
facebook
Hướng dẫn thêm chức năng JSI mới vào lớp Giao diện JavaScript (JSI). Sử dụng khi người dùng yêu cầu thêm, tạo hoặc triển khai các phương thức hoặc tính năng mới trong…
official
non-interactive-git-rebase
facebook
Sử dụng khi cần sắp xếp lại, tách, bỏ hoặc sửa đổi các commit git không phải là commit trên cùng, mà không cần truy cập trình chỉnh sửa tương tác. Bao gồm rebase theo chương trình thông qua…
official
click-target
facebook
Tìm và nhấp vào đối tượng mục tiêu trong XR. Sử dụng khi kiểm tra tương tác giao diện, nhấp nút hoặc xác minh các phần tử có thể tương tác hoạt động chính xác.
official
iwsdk-planner
facebook
Hướng dẫn lập kế hoạch dự án IWSDK và các phương pháp tốt nhất. Sử dụng khi lập kế hoạch tính năng IWSDK mới, thiết kế hệ thống/thành phần, xem xét kiến trúc mã IWSDK, hoặc khi…
official
iwsdk-ui-panel
facebook
Phát triển và lặp lại các bảng điều khiển giao diện IWSDK một cách hiệu quả. Sử dụng khi làm việc với các thành phần PanelUI, gỡ lỗi bố cục giao diện, hoặc cải thiện thiết kế giao diện trong các ứng dụng IWSDK.
official
test-all
facebook
Bộ điều phối kiểm thử song song. Chạy đồng thời tất cả 9 bộ kiểm thử thông qua các tác tử con Task và CLI iwsdk. Xử lý build, thiết lập ví dụ, máy chủ dev, khởi chạy tác tử,…
official
test-audio
facebook
Kiểm tra hệ thống âm thanh (tải AudioSource, trạng thái phát, dừng, âm thanh không gian) so với ví dụ âm thanh sử dụng CLI iwsdk.
official