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.
Security Assessment
Detected risks:
About coreml
This skill provides comprehensive guidance for integrating Core ML models into iOS applications, enabling on-device machine learning inference without requiring network connectivity or cloud resources. It focuses exclusively on the Swift implementation side, covering model loading from various sources (.mlmodel, .mlpackage, .mlmodelc), configuration of compute resources, and execution of predictions using Apple's Core ML framework.
The skill encompasses critical integration patterns including auto-generated model classes for type-safe predictions, manual and asynchronous model loading strategies, compute unit configuration to optimize performance across CPU, GPU, and Neural Engine, MLTensor usage for modern iOS versions, MLMultiArray handling for older compatibility, and Vision framework integration for computer vision tasks. It also addresses multi-model pipelines, performance profiling techniques, and memory management strategies essential for production deployment.
Targeted at iOS developers building machine learning features into their apps, this skill is particularly valuable when implementing on-device inference for privacy-sensitive applications, offline-capable ML features, or performance-critical scenarios where latency matters. It supports iOS 26+ with Swift 6.3 while maintaining backward compatibility to iOS 14 where applicable, and explicitly excludes Python-side model conversion and optimization topics, which are covered by the complementary apple-on-device-ai skill.
FAQ
What iOS versions does this skill support?
This skill targets iOS 26+ with Swift 6.3, but most patterns are backward-compatible to iOS 14. Specific features like MLTensor require iOS 18+, async loading requires iOS 15+, and runtime compilation requires iOS 16+.
When should I use .all versus .cpuAndNeuralEngine for compute units?
Use .all as the default to let the system choose optimal hardware. Use .cpuAndNeuralEngine (iOS 16+) when you've profiled and confirmed the model is Neural Engine compatible and need best energy efficiency. Use .cpuOnly only for deterministic testing or when profiling shows accelerator contention is limiting performance.
Should I use auto-generated classes or manual MLModel loading?
Use auto-generated classes whenever possible for type safety and cleaner code. Manual loading is necessary when models are downloaded at runtime, stored outside the app bundle, or when you need dynamic model selection.
Do I need to recompile .mlpackage files on every app launch?
No, this is a common mistake. Use MLModel.compileModel(at:) once when first downloading the model, cache the compiled .mlmodelc URL in persistent storage (like Application Support), and reuse it on subsequent launches.
Does this skill cover model training or conversion from TensorFlow/PyTorch?
No, this skill focuses exclusively on Swift-side integration of already-converted Core ML models. Model conversion, optimization (quantization, pruning), and framework-specific preparation are covered in the separate apple-on-device-ai skill.
Install coreml
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
dpearson2699/swift-ios-skills