dat-conventions

Swift patterns, async/await, naming conventions, key types for DAT SDK iOS development

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

DAT SDK Conventions (iOS)

Architecture

The public SDK is organized into these modules:

  • MWDATCore: Device discovery, registration, permissions, device selectors, DeviceSession
  • MWDATCamera: Camera, Stream, VideoFrame, photo capture
  • MWDATDisplay: Display capability, display UI components, icons, images, buttons, video
  • MWDATMockDevice: MockDeviceKit for testing without hardware
  • MWDATMockDeviceTestClient: MockDeviceTestClient for driving MockDeviceKit over HTTP from a UI-test process

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 (an any WearablesInterface)
  • DeviceSession — The connection to a selected device. Create with createSession(deviceSelector:), then attach capabilities
  • Camera — Camera capability from session.addCamera(config:); owns camera.stream
  • Stream — Camera stream: start(), stop(), capturePhoto(format:), and the frame/state/photo/error publishers
  • Display — Display capability from session.addDisplay()
  • VideoFrame — Individual video frame with .makeUIImage() and .sampleBuffer
  • Device / DeviceIdentifier — DeviceIdentifier is a String; resolve a Device with deviceForIdentifier(_:)
  • AutoDeviceSelector — Selects the best available device, optionally filtered (filter: { $0.supportsDisplay() })
  • SpecificDeviceSelector — Selects a specific device by DeviceIdentifier
  • StreamConfiguration — Configure video codec, resolution, frame rate
  • ListenerTokenBag / AnyListenerToken — Keep .listen {} subscriptions alive; dropping a token cancels it
  • 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.

See the dat-docs-mcp skill for Claude Code, Cursor, and MCP Inspector setup and troubleshooting.

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

Links

More skills from facebook

gc-safe-coding
facebook
For the full explanation and rationale, see doc/GCSafeCoding.md .
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…
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…
debug-webhooks
facebook
Troubleshoot webhook issues for a Meta app — inspect active subscriptions, identify misconfiguration, and send test payloads to verify delivery. Use when…
api-integration
facebook
Guide a developer through setting up a Meta API integration from scratch — discovers the right APIs, fetches setup guides, authentication requirements,…
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…
test-ui
facebook
Test UI system (PanelUI, ScreenSpace) against the poke example using the iwsdk CLI.
flags
facebook
Inspect and compare feature flag states across React release channels. View all flags across channels (www, www-modern, canary, next, experimental, rn variants) or compare specific channels with --diff Output formats include default table view, CSV export, and cleanup status grouping Flag states indicated by symbols: enabled (✅), disabled (❌), variant testing (🧪), profiling-only (📊) Common pitfall: __VARIANT__ flags are tested in both states on www; use --diff to spot meaningful...