| name | dat-conventions |
| description | Swift patterns, async/await, naming conventions, key types for DAT SDK iOS development |
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
| Type | Convention | Example |
|---|
| Entry point | Wearables.shared | Wearables.shared.startRegistration() |
| Device sessions | *Session | DeviceSession |
| Capabilities | Named by function | Stream |
| Selectors | *DeviceSelector | AutoDeviceSelector, SpecificDeviceSelector |
| Config | *Configuration | StreamConfiguration |
| Publishers | *Publisher | statePublisher, videoFramePublisher |
Imports
import MWDATCore
import MWDATCamera
import MWDATDisplay
For testing:
import MWDATMockDevice
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 {
}
do {
try await Wearables.shared.startRegistration()
} catch {
}
Build and Test
xcodebuild -scheme MWDATCore -destination 'platform=iOS Simulator,name=iPhone 16'
xcodebuild test -scheme MWDATCoreTests -destination 'platform=iOS Simulator,name=iPhone 16'
For sample apps:
open ExternalSampleApps/CameraAccess/CameraAccess.xcodeproj
xcodebuild -scheme CameraAccess -destination 'platform=iOS Simulator,name=iPhone 16'
Development Workflow
- Add SDK via Swift Package Manager (SPM) in Xcode
- Import modules (
MWDATCore, MWDATCamera, MWDATDisplay when rendering Display content)
- Configure at app launch:
try Wearables.configure()
- Build with Xcode or
xcodebuild
- Test with MockDeviceKit - no physical glasses required
- 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