Community研究与数据分析github.com

dpearson2699/sensorkit

访问研究级传感器数据,专为获批研究设计的 SensorKit 技能。适用于需要 SensorKit 授权设置、研究传感器与使用数据授权、环境光、录制的运动、设备使用、键盘指标、访问、语音、面部、手腕温度、心电图、PPG、声学设置或睡眠会话数据的应用。将普通运动路由至 CoreMotion,健康记录/健身数据路由至 HealthKit。

sensorkit 是什么?

该技能(dpearson2699/sensorkit)旨在帮助开发者在 iOS 应用中集成 SensorKit,以访问研究级传感器数据。它主要用于需要 SensorKit 授权设置、研究传感器与使用数据授权、环境光、运动记录、设备使用、键盘指标、访问、语音、面部、手腕温度、心电图、PPG、声学设置或睡眠会话数据的获批研究应用。技能还指导将普通运动数据路由至 CoreMotion,健康记录和健身数据路由至 HealthKit。它支持 iOS 平台,且要求应用获得 SensorKit 授权。使用该技能时,需在 Xcode 项目设置中启用 SensorKit 能力,并确保 Info.plist 包含必要的权限描述(如 NSMotionUsageDescription)。该技能通过提供的 SKILL.md 文档,详细说明了如何设置授权、配置 Info.plist、导入 SensorKit 框架,以及如何使用各种传感器数据,例如使用 SRSensor 枚举选择传感器,使用 SRReader 创建数据读取请求。对于普通运动数据,建议使用 CoreMotion 的 CMMotionManager,而健康数据则通过 HealthKit 的 HKHealthStore 来记录。总之,该技能简化了 SensorKit 的集成过程,使开发者能够专注于研究数据的分析,而无需处理复杂的系统配置。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/dpearson2699/swift-ios-skills/tree/main/skills/sensorkit

Installed? Explore more 研究与数据分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

sensorkit 是做什么的?

使用 SensorKit 访问研究级传感器数据,适用于获批研究。当应用需要 SensorKit 授权设置、研究传感器与使用数据授权、环境光、录制的运动、设备使用、键盘指标、访问、语音、面部、手腕温度、心电图、PPG、声学设置或睡眠会话数据时使用。将普通运动路由至 CoreMotion,健康记录/健身数据路由至 HealthKit。

概述

SensorKit 是苹果提供的一个框架,允许经过批准的研究应用访问来自 iOS 设备的高保真传感器数据。本技能指导开发者如何设置 SensorKit 授权、配置 Info.plist,以及使用各种传感器数据类型。

设置步骤

  1. 启用 SensorKit 能力:在 Xcode 项目中,前往 Signing & Capabilities,添加 SensorKit 能力。
  2. 配置 Info.plist:添加以下键:
    • NSMotionUsageDescription:描述应用如何使用运动数据。
    • NSSpeechRecognitionUsageDescription:如果使用语音数据。
    • 其他可能需要的权限字符串。
  3. 导入框架:在代码中导入 import SensorKit。

使用传感器数据

请求授权

import SensorKit

SRReader.requestAuthorization(for: [.ambientLight, .motion]) { granted, error in
    if granted {
        // 开始数据收集
    }
}

枚举传感器

SRSensor 枚举支持以下传感器:

  • .ambientLight:环境光数据
  • .motion:录制的运动数据
  • .deviceUsage:设备使用数据
  • .keyboardMetrics:键盘指标
  • .visits:访问数据
  • .speech:语音数据
  • .face:面部数据
  • .wristTemperature:手腕温度
  • .electrocardiogram:心电图
  • .photoplethysmogram:PPG
  • .acousticSettings:声学设置
  • .sleepSession:睡眠会话数据

使用 SRReader 读取数据

let reader = SRReader(sensor: .ambientLight)
reader.startRecording()
// 处理数据...
reader.stopRecording()

路由建议

  • 普通运动:使用 CoreMotion 的 CMMotionManager 处理,例如:
    import CoreMotion
    let motionManager = CMMotionManager()
    motionManager.startDeviceMotionUpdates(to: .main) { data, error in
        // 处理设备运动数据
    }
    
  • 健康记录/健身:使用 HealthKit 的 HKHealthStore 保存数据:
    import HealthKit
    let healthStore = HKHealthStore()
    // 请求授权并保存数据
    

注意事项

  • 确保应用已获得苹果研究审查委员会的批准才能使用 SensorKit。
  • 用户必须通过设置应用显式授予 SensorKit 权限。
  • 所有数据收集必须在用户知情同意下进行。

资源

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

dpearson2699/accessorysetupkit

Discover and configure Bluetooth and Wi-Fi accessories using AccessorySetupKit. Use when presenting a privacy-preserving accessory picker, defining discovery descriptors for BLE or Wi-Fi devices, handling accessory session events, migrating from CoreBluetooth permission-based scanning, or setting up accessories without requiring broad Bluetooth permissions.

dpearson2699/activitykit

Implement, review, or improve Live Activities and Dynamic Island experiences in iOS apps using ActivityKit. Use when building real-time updating widgets for the Lock Screen and Dynamic Island — delivery tracking, sports scores, ride-sharing status, workout timers, media playback, or any time-sensitive information that updates in real time. Also use when working with ActivityKit, ActivityAttributes, Activity lifecycle (request/update/end), Dynamic Island layouts (compact/minimal/expanded), push-to-update Live Activities, or Lock Screen live widgets.

dpearson2699/adattributionkit

Measure ad effectiveness with privacy-preserving attribution using AdAttributionKit. Use when registering ad impressions, handling attribution postbacks, updating conversion values, implementing re-engagement attribution, configuring publisher or advertiser apps, or replacing SKAdNetwork with AdAttributionKit for ad measurement.

dpearson2699/alarmkit

Implement AlarmKit alarms and countdown timers for iOS and iPadOS with Lock Screen, Dynamic Island, and Apple Watch system UI. Covers AlarmManager scheduling, AlarmAttributes and AlarmPresentation, AlarmButton stop and snooze actions, authorization, state observation, and Live Activity integration. Use when building wake-up alarms, countdown timers, or alarm-style alerts that need Apple's system alarm experience.

dpearson2699/app-clips

Build iOS App Clips with invocation URLs, App Clip Codes, NFC, QR codes, Safari banners, Maps, Messages, target setup, App Store Connect experiences, size/capability constraints, NSUserActivity routing, SKOverlay promotion, App Group/keychain handoff, ephemeral notifications, location confirmation, and full-app migration. Use when creating App Clips or wiring App Clip invocation, experience configuration, or full-app handoff.

dpearson2699/app-intents

Implement App Intents for Siri, Shortcuts, Spotlight, widgets, Control Center, and Apple Intelligence on iOS. Covers AppIntent actions, AppEntity and EntityQuery models, AppShortcutsProvider phrases, IndexedEntity Spotlight indexing, WidgetConfigurationIntent, SnippetIntent, and assistant schemas. Use when exposing app actions or entities to system surfaces.

dpearson2699/apple-on-device-ai

Integrate on-device AI using Foundation Models framework, Core ML, and open-source LLM runtimes on Apple Silicon. Covers Foundation Models (LanguageModelSession, @Generable, @Guide, SystemLanguageModel, structured output, tool calling), Core ML (coremltools, model conversion, quantization, palettization, pruning, Neural Engine, MLTensor), MLX Swift (transformer inference, unified memory), and llama.cpp (GGUF, cross-platform LLM). Use when building tool-calling AI features, working with guided generation schemas, converting models, or running on-device inference.

dpearson2699/appmigrationkit

Transfer app data to or from other platforms using AppMigrationKit. Use when implementing system-orchestrated one-time migration between iOS and Android or another platform, building an AppMigrationExtension, packaging transportable resources with ResourcesArchiver, importing resources on the destination device, reporting import progress, handling migration errors and app group cleanup, checking MigrationStatus, or testing migration code with AppMigrationTester.

dpearson2699/app-store-review

Prepare for App Store review and prevent rejections. Covers App Store review guidelines, app rejection reasons, PrivacyInfo.xcprivacy privacy manifest requirements, required API reason codes, in-app purchase IAP and StoreKit rules, App Store Guidelines compliance, ATT App Tracking Transparency, EU DMA Digital Markets Act, HIG compliance checklist, app submission preparation, review preparation, metadata requirements, entitlements, widgets, and Live Activities review rules. Use when preparing for App Store submission, fixing rejection reasons, auditing privacy manifests, implementing ATT consent flow, configuring StoreKit IAP, or checking HIG compliance.

dpearson2699/audioaccessorykit

Support audio accessory features like automatic switching using AudioAccessoryKit. Use when implementing automatic audio routing for paired accessories, registering audio accessory configuration from the container app, updating placement or connected audio source identifiers from an app extension, or handling AccessoryControlDevice capabilities and errors.

dpearson2699/authentication

Implement iOS authentication flows with AuthenticationServices and LocalAuthentication. Use when building Sign in with Apple, passkey/WebAuthn registration or sign-in with ASAuthorizationPlatformPublicKeyCredentialProvider, ASAuthorizationController credential state and revocation handling, ASWebAuthenticationSession OAuth or third-party login, Password AutoFill, identity-token server validation, or local biometric re-authentication with LAContext.

dpearson2699/avkit

Create media playback experiences using AVKit. Use when adding video players with AVPlayerViewController, enabling Picture-in-Picture, routing media with AirPlay, using SwiftUI VideoPlayer views, configuring transport controls, displaying subtitles and closed captions, or integrating AVFoundation playback with system UI.

dpearson2699/background-processing

Schedule and execute background work on iOS using BGTaskScheduler. Use when registering BGAppRefreshTask for short background fetches, BGProcessingTask for long-running maintenance, BGContinuedProcessingTask (iOS 26+) for foreground-started work that continues in background, background URLSession downloads, or background push notifications. Covers Info.plist configuration, expiration handling, task completion, and debugging with simulated launches.

dpearson2699/browserenginekit

Build alternative browser engines using BrowserEngineKit. Use when developing a non-WebKit browser engine for iOS/iPadOS in supported regions, managing web content/rendering/networking extension processes, configuring GPU and networking process capabilities, checking alternative-engine device eligibility, or reviewing BrowserEngineKit entitlements and Info.plist setup.

dpearson2699/callkit

Implement VoIP calling with CallKit and PushKit. Use when building incoming/outgoing call flows, registering for VoIP push notifications, configuring CXProvider and CXCallController, handling call actions, coordinating audio sessions, or creating Call Directory extensions for caller ID and call blocking.

dpearson2699/carplay

Build CarPlay-enabled apps using the CarPlay framework. Use when creating navigation, audio, communication, EV charging, parking, or food ordering apps for the car display, working with CPTemplateApplicationScene, CPInterfaceController template hierarchies, CPListTemplate, CPMapTemplate, CPNowPlayingTemplate, configuring CarPlay entitlements, or integrating with CarPlay Simulator for testing.

dpearson2699/cloudkit

Implement, review, or improve CloudKit and iCloud sync in iOS/macOS apps. Use when working with CKContainer, CKRecord, CKQuery, CKSubscription, CKSyncEngine, CKShare, NSUbiquitousKeyValueStore, or iCloud Drive file coordination; when syncing SwiftData models via ModelConfiguration with cloudKitDatabase; when handling CKError codes for conflict resolution, network failures, or quota limits; or when checking iCloud account status before performing sync operations.

dpearson2699/contacts-framework

Read, create, update, and pick contacts using the Contacts and ContactsUI frameworks. Use when fetching contact data, saving new contacts, wrapping CNContactPickerViewController in SwiftUI, handling contact permissions, or working with CNContactStore fetch and save requests.

dpearson2699/core-bluetooth

Build direct Bluetooth Low Energy workflows with Core Bluetooth. Use when implementing BLE central or peripheral GATT communication, scanning or connecting with CBCentralManager, discovering services and characteristics, reading/writing/subscribing with CBPeripheral, publishing local services with CBPeripheralManager, handling Bluetooth authorization, background BLE modes, state restoration, write flow control, or CBUUID-based workflows. For privacy-preserving accessory setup/picker flows, use accessorysetupkit first and return here for post-setup GATT communication.

dpearson2699/coreml

Integrate Core ML models in iOS apps for on-device machine learning inference. Covers model loading (.mlmodel, .mlpackage, .mlmodelc), predictions with auto-generated classes and MLFeatureProvider, compute unit configuration (CPU, GPU, Neural Engine), MLTensor, VNCoreMLRequest, MLComputePlan, multi-model pipelines, and deployment strategies. Use when loading Core ML models, making predictions, configuring compute units, or profiling model performance.

相关技能