coremllisted
Install: claude install-skill thienqo/ios-skills
# Core ML Swift Integration
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.
## Contents
- [Loading Models](#loading-models)
- [Model Configuration](#model-configuration)
- [Making Predictions](#making-predictions)
- [MLTensor (iOS 18+)](#mltensor-ios-18)
- [Vision Integration](#vision-integration)
- [Performance & Memory](#performance--memory)
- [Common Mistakes](#common-mistakes)
- [Review Checklist](#review-checklist)
- [References](#references)
## Loading Models
- **Auto-Generated Class**: Add `.mlmodel` or `.mlpackage` to the target; Xcode generates typed input/output classes.
- **Async Loading (iOS 15+)**: Avoid blocking the main thread: `try await MLModel.load(contentsOf: url, configuration: config)`.
- **Runtime Compilation (iOS 16+)**: Compile downloaded packages with `MLModel.compileModel(at: url)`. Cache the resulting `.mlmodelc` URL in Application Support; recompiling on every launch is an error.
```swift
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)
```
##