Display capability setup, display-capable device selection, UI DSL, icons, buttons, images, and video playback
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "display-access" 技能: 1. 下载 https://raw.githubusercontent.com/facebook/meta-wearables-dat-ios/main/plugins/mwdat-ios/skills/display-access/SKILL.md 2. 保存为 ~/.claude/skills/display-access/SKILL.md 3. 装好后重载技能,告诉我可以用了
Use MWDATDisplay to render content on Meta Ray-Ban Display glasses.
Use this skill with getting-started and permissions-registration when creating a full app. A Display app still needs Wearables.configure() at launch, Info.plist URL scheme configuration, URL callbacks through Wearables.shared.handleUrl(_:), and completed Meta AI registration before it can create a session.
Add MWDATDisplay to the same app target that already uses MWDATCore. Import it next to core:
import MWDATCore
import MWDATDisplay
Use the getting-started Info.plist setup, then mirror the DisplayAccess sample for Display sessions:
CFBundleURLTypes URL scheme and route callbacks to Wearables.shared.handleUrl(_:).MWDAT, set AppLinkURLScheme, MetaAppID, ClientToken, TeamID, and DAMEnabled = true. MetaAppID = 0 is for Developer Mode; production apps should use Wearables Developer Center values for MetaAppID and ClientToken, plus the Apple Developer Team ID.UISupportedExternalAccessoryProtocols with com.meta.ar.wearable, UIBackgroundModes entries for external-accessory and bluetooth-central, and NSBluetoothAlwaysUsageDescription. The DisplayAccess sample also includes bluetooth-peripheral and processing.NSLocalNetworkUsageDescription and NSBonjourServices. Display acquires link leases: core device discovery/session setup uses medium then low links, while Display uses medium then high links when available.Use the public display filter when creating an automatic selector:
let wearables = Wearables.shared
let deviceSelector = AutoDeviceSelector(
wearables: wearables,
filter: { device in device.supportsDisplay() }
)
Use SpecificDeviceSelector(device: selectedDevice.identifier) instead when your UI lets the user pick a specific Device. The initializer takes a DeviceIdentifier, not the whole Device.
AutoDeviceSelector updates from devicesStream(). Create it before the user taps the Display action, or wait for activeDeviceStream() to yield a non-nil device before calling createSession(deviceSelector:); otherwise createSession can throw DeviceSessionError.noEligibleDevice.
For a picker or Settings screen, list devices from Wearables.shared.devicesStream(), then look up metadata from deviceForIdentifier(_:). The DisplayAccess sample shows nameOrId(), deviceType().rawValue, linkState, and compatibility() and keeps addLinkStateListener / addCompatibilityListener tokens alive while rows are visible. If compatibility() == .deviceUpdateRequired, surface a firmware update action through Wearables.shared.openFirmwareUpdate().
Create and start the DeviceSession, wait for .started, then add and start Display. Keep the state listener token alive for as long as you need updates, and observe session.errorStream() for async session failures.
import MWDATCore
import MWDATDisplay
@MainActor
final class DisplayController {
private var deviceSession: DeviceSession?
private var display: Display?
private var displayStateToken: AnyListenerToken?
private var sessionErrorTask: Task<Void, Never>?
func connect() async {
do {
let wearables = Wearables.shared
let selector = AutoDeviceSelector(
wearables: wearables,
filter: { $0.supportsDisplay() }
)
let session = try wearables.createSession(deviceSelector: selector)
deviceSession = session
sessionErrorTask = Task { [weak self] in
for await error in session.errorStream() {
await self?.showError(error.localizedDescription)
}
}
let sessionStarted = Task {
for await state in session.stateStream() {
…
Stream, video frames, photo capture, resolution/frame rate configuration
Device session states, pause/resume, availability monitoring
Swift patterns, async/await, naming conventions, key types for DAT SDK iOS development
Common issues, Developer Mode, version compatibility, state machine diagnosis
SDK setup, Swift Package Manager integration, Info.plist configuration, and first connection to Meta glasses
MockDeviceKit for testing without physical glasses hardware