Loads, configures, and runs Core ML models in iOS apps. Covers Swift model loading, typed/dynamic prediction, batch inference, MLTensor, Vision integration, compute-unit selection, profiling, and memory management.
Ships in all-ios-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Load, configure, and run Core ML models in iOS apps. Covers Swift model loading, synchronous/async inference, batch prediction, MLTensor, profiling, and memory management.
Scope boundary: Python-side model conversion, quantization, and pruning belong in
apple-on-device-ai. This skill owns Swift-side integration only.
.mlmodel or .mlpackage to the target; Xcode generates typed input/output classes.try await MLModel.load(contentsOf: url, configuration: config).MLModel.compileModel(at: url). Cache the resulting .mlmodelc URL in Application Support; recompiling on every launch is an error.import CoreML
let config = MLModelConfiguration()
config.computeUnits = .all
// Typed model initialization
let classifier = try MyImageClassifier(configuration: config)
// Dynamic async loading
let model = try await MLModel.load(contentsOf: modelURL, configuration: config)
MLModelConfiguration controls compute dispatch:
| Value | Hardware Target | Best For |
|---|---|---|
.all | CPU + GPU + Neural Engine | Default. Best overall performance. |
.cpuAndNeuralEngine | CPU + Neural Engine | Energy efficiency, keeping GPU free for rendering. |
.cpuAndGPU | CPU + GPU | Models with operations unsupported by Neural Engine. |
.cpuOnly | CPU only | Deterministic tests, profiling baseline, background tasks. |
MLModel.prediction(...) is synchronous. Keep model loading asynchronous, then dispatch synchronous predictions from an actor or background task without adding await to prediction().
// 1. Typed prediction
let input = MyImageClassifierInput(image: pixelBuffer)
let output = try classifier.prediction(input: input)
// 2. Dynamic feature provider
let features = try MLDictionaryFeatureProvider(dictionary: ["image": MLFeatureValue(pixelBuffer: pixelBuffer)])
let dynamicOutput = try model.prediction(from: features)
// 3. Batch prediction (better throughput)
let batch = try MLArrayBatchProvider(array: featureArray)
let batchResults = try model.predictions(fromBatch: batch)
// 4. Stateful prediction (iOS 18+ for sequences/LLMs)
let state = model.makeState()
let stateOutput = try model.prediction(from: features, using: state)
Predictions sharing the same MLState must be serialized; allocate independent MLState instances for concurrent streams.
MLTensor provides Swift-native multidimensional tensor math with lazy evaluation:
let tensor = MLTensor([1.0, 2.0, 3.0, 4.0]).reshaped(to: [2, 2])
let softmax = tensor.softmax(alongAxis: -1)
// Materialize asynchronously
let shapedArray = await softmax.shapedArray(of: Float.self)
let multiArray = try MLMultiArray(shapedArray)
Prefer Vision pipelines to automatically handle image orientation, resizing, and pixel buffer formatting:
CoreMLRequest with Swift async/await concurrency.VNCoreMLModel(for: model) with VNCoreMLRequest and VNImageRequestHandler.try await MLComputePlan.load(contentsOf: url, configuration: config).actor, unload on memory pressure or background transitions, and share instances rather than reloading per request.MLModel.load(contentsOf:configuration:) asynchronously..compileModel(at:) outputs to Application Support.MLState instance is not thread-safe for concurrent calls. Serialize predictions or create separate states.CoreMLRequest instead.computeUnits chosen based on profiling and thermal constraintspredictions(fromBatch:)) used for multi-sample throughputCoreMLRequest) utilized for image inputsMLComputePlan inspected on iOS 17.4+ to verify Neural Engine offloadapple-on-device-aiWhat SKILL.md sets; muted values are Claude Code's defaults
/all-ios-skills:coremlfrom all-ios-skills
npx claudepluginhub thienqo/ios-skills --plugin all-ios-skills95 skills in this plugin
/accessorysetupkitDiscover 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./activitykitBuild or review Live Activities and Dynamic Island experiences with ActivityKit, including lifecycle, layouts, push updates, and scheduled delivery. Use for time-sensitive Lock Screen or Dynamic Island state; route ordinary widgets to widgetkit./adattributionkitMeasure 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.Other plugins' skills for the same job