Communityコーディング&開発github.com

dpearson2699/coreml

iOSアプリにCore MLモデルを統合し、デバイス上で機械学習推論を実行します。モデルの読み込み(.mlmodel、.mlpackage、.mlmodelc)、自動生成クラスとMLFeatureProviderを用いた予測、計算ユニット設定(CPU、GPU、Neural Engine)、MLTensor、VNCoreMLRequest、MLComputePlan、マルチモデルパイプライン、デプロイ戦略をカバーします。Core MLモデルの読み込み時、予測の実行時、計算ユニットの設定時、またはモデルのパフォーマンスプロファイリング時に使用します。

coreml とは?

このスキルは、iOSアプリ内でCore MLモデルを利用したオンデバイス機械学習推論を統合・実行するための包括的なガイドです。対応プラットフォームはiOS、macOS、watchOS、tvOSなどAppleプラットフォーム全般で、`.mlmodel`、`.mlpackage`、`.mlmodelc`形式のモデル読み込みに対応します。主な機能として、自動生成されたクラスやMLFeatureProviderを使った予測、CPU・GPU・Neural Engine間の計算ユニット設定、MLTensorによるテンソル操作、VNCoreMLRequestを使ったVision統合、MLComputePlanによるモデルパフォーマンスプロファイリング、複数モデルを連結するパイプライン構築、そしてバンドル・ダウンロード・コンパイルを含むデプロイ戦略をカバーします。開発者はこのスキルを活用することで、Core MLモデルの読み込み、予測実行、計算ユニット設定、パフォーマンス評価を効率的に行えます。

対応~Claude Code~Codex CLI~Cursor
Part ofMobile
npx skills add https://github.com/dpearson2699/swift-ios-skills/tree/main/skills/coreml

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

coreml は何をしますか?

iOSアプリにCore MLモデルを統合し、デバイス上で機械学習推論を実行します。モデルの読み込み(.mlmodel、.mlpackage、.mlmodelc)、自動生成クラスとMLFeatureProviderを用いた予測、計算ユニット設定(CPU、GPU、Neural Engine)、MLTensor、VNCoreMLRequest、MLComputePlan、マルチモデルパイプライン、デプロイ戦略をカバーします。Core MLモデルの読み込み時、予測の実行時、計算ユニットの設定時、またはモデルのパフォーマンスプロファイリング時に使用します。

モデルの読み込み

Core MLモデルは.mlmodel(コンパイル済み)または.mlpackage(パッケージ形式)として読み込めます。コンパイル済みモデルは.mlmodelc形式で、読み込みが高速化されます。

let model = try MLModel(contentsOf: modelURL)

予測の実行

自動生成されたクラスを使用するか、MLFeatureProviderプロトコルを実装して予測を行います。

自動生成クラスを使用

let model = try MyModel(configuration: config)
let output = try model.prediction(input: MyModelInput(feature: value))

MLFeatureProviderを使用

let inputFeatures = try MLDictionaryFeatureProvider(dictionary: ["input": value])
let output = try model.prediction(from: inputFeatures)

計算ユニット設定

MLModelConfigurationのcomputeUnitsプロパティで推論に使用するハードウェアを指定します。

let config = MLModelConfiguration()
config.computeUnits = .all  // CPU, GPU, Neural Engineをすべて使用
// 他のオプション: .cpuOnly, .cpuAndGPU, .cpuAndNeuralEngine
let model = try MLModel(contentsOf: modelURL, configuration: config)

MLTensorの使用

MLTensorはテンソル形式のデータを直接扱えます。

let tensor = MLTensor(shape: [1, 224, 224, 3], dataType: .float32)

VNCoreMLRequestとの統合

Visionフレームワークと統合し、画像認識を効率的に実行します。

let model = try VNCoreMLModel(for: MyModel().model)
let request = VNCoreMLRequest(model: model) { request, error in
    // 結果を処理
}

MLComputePlanによるプロファイリング

モデルのパフォーマンスを分析します。

let plan = try MLComputePlan(for: model)
print(plan.performanceMetrics)

マルチモデルパイプライン

複数のモデルを連結してパイプラインを構築できます。

let pipeline = try MLModelPipeline(models: [model1, model2, model3])
let output = try pipeline.prediction(from: input)

デプロイ戦略

モデルをバンドルとしてアプリに含めるか、ダウンロードしてからコンパイルする方法があります。

バンドル

アプリのバンドルに直接モデルファイルを含めます。

ダウンロードとコンパイル

let compiledURL = try MLModel.compileModel(at: downloadedModelURL)
let model = try MLModel(contentsOf: compiledURL)

注意事項

  • モデルのサイズと複雑さに応じてパフォーマンスが変わります。MLComputePlanで事前にプロファイリングすることを推奨します。
  • 計算ユニットの設定はターゲットデバイスのハードウェアに依存します。Neural EngineはA12以降のチップで利用可能です。
  • モデルをダウンロードする場合は、ユーザーのプライバシーとネットワーク使用量に注意してください。

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/core-motion

Access Core Motion accelerometer, gyroscope, magnetometer, device-motion, pedometer, activity-recognition, altitude, headphone motion, batched high-frequency workout motion, and water-submersion/depth data. Use when reading device sensors, counting steps, detecting walking/running/driving/cycling, tracking altitude, building motion interactions, handling AirPods head tracking, or implementing watchOS dive/depth features.

関連スキル