Core ML — a machine learning framework from Apple, optimized for running ML models directly on iOS, macOS, watchOS, and tvOS devices. Unlike cloud-based ML services, Core ML uses Apple’s hardware accelerators: Neural Engine, GPU, and CPU, ensuring minimal latency when processing data. According to Apple Core ML Documentation (2026), the framework supports PyTorch, TensorFlow, and Create ML models in a unified .mlpackage format with an average inference time of 5–50 ms.
Key Takeaways
Core ML is a machine learning framework introduced by Apple at WWDC 2017 as part of the development ecosystem for iPhone, iPad, Mac, Apple Watch, and Apple TV. Core ML provides a runtime for executing ML models on device, abstracting developers from the details of hardware optimization. The framework automatically selects the best compute engine — Neural Engine on A12+ chips, GPU, or CPU — for each model operation.
The key advantage of Core ML is deep integration with Apple Silicon. Neural network operations run on the dedicated Neural Engine, which does not load the main processor cores. According to Apple (WWDC 2025), Core ML models run 6 times faster compared to TensorFlow Lite on similar Android devices.
Core ML supports a wide range of machine learning tasks: image classification, object detection, semantic segmentation, natural language processing, sound analysis, and tabular data. The framework works with various model types: neural networks (convolutional, recurrent, transformers), tree ensembles, linear regressions, and Gaussian processes.
Core ML takes a trained model in .mlpackage format as input, compiles it into optimized machine code for the specific device, and runs inference through a unified API. The entire pipeline — from loading the model to getting the result — takes 3–5 lines of Swift code.
.mlpackage is a container format introduced by Apple in 2020 to replace the outdated .mlmodel. The package is a directory containing a JSON manifest, a model file in binary MLProgram format, metadata (author, version, description), and resources such as class labels. According to Apple, .mlpackage reduces model size by 30–50% compared to .mlmodel through weight optimization.
Apple Neural Engine (ANE) is a dedicated neural processor built into Apple chips starting with the A12 Bionic (2018). ANE processes matrix operations tens of times more efficiently than CPU at the same power consumption. ANE performance has grown from 5 TOPS on A12 to 35 TOPS on M4 Ultra (2025), enabling models with billions of parameters. ANE is used automatically for all Core ML models with neural network architecture.
An important feature of Core ML is support for quantization of models to FP16 and INT8 without loss of accuracy. Quantization reduces model size by 2–4 times and speeds up inference by 40–60% on ANE. Apple provides the Xcode Model Quantization tool for automatic optimal precision selection: the developer uploads a model, specifies the acceptable quality loss (usually 0.1–0.5%), and Xcode selects the best weight representation format.
| Chip | TOPS (ANE) | ResNet-50 Inference | Year |
|---|---|---|---|
| A12 Bionic | 5 | 18 ms | 2018 |
| A14 Bionic | 11 | 9 ms | 2020 |
| M1 Max | 22 | 4 ms | 2021 |
| M4 Ultra | 35 | 2 ms | 2025 |
Most ML models are created in PyTorch or TensorFlow and need conversion to .mlpackage format for use in Core ML. Apple provides the coremltools utility — a Python package for converting, optimizing, and validating models.
coremltools is Apple’s official utility for converting ML models. It supports import from PyTorch (via torch.onnx or directly), TensorFlow (SavedModel, H5, Frozen Graph), and ONNX. After conversion, FP16 or INT8 quantization can be enabled, reducing model size by 2–4 times without significant accuracy loss.
Let’s look at converting a trained PyTorch model to Core ML format using coremltools version 8.0. The process takes 2–3 steps in Python.
import torch
import coremltools as ct
# Loading trained PyTorch model
model = torch.load('model.pth')
model.eval()
# Tracing model with example input
example_input = torch.randn(1, 3, 224, 224)
traced_model = torch.jit.trace(model, example_input)
# Converting to Core ML .mlpackage
mlmodel = ct.convert(
traced_model,
convert_to='mlprogram',
inputs=[ct.TensorType(shape=(1, 3, 224, 224))]
)
mlmodel.save('Model.mlpackage')
The code loads the trained PyTorch model, performs JIT tracing with a sample input, and converts it to mlprogram format (Core ML binary format). The resulting .mlpackage can be dragged into Xcode and used immediately in Swift code.
After model conversion, integrating it into an iOS app in Swift takes just a few lines. Xcode automatically generates a Swift class for the model based on .mlpackage metadata.
Let’s look at an example of image classification using Core ML and the Vision framework. Vision automatically transforms the image to the required size and pixel format.
import CoreML
import Vision
// Loading Core ML model
guard let model = try? VNCoreMLModel(
for: MobileNetV2.configuration.model
) else { return }
// Creating VNCoreMLRequest
let request = VNCoreMLRequest(model: model) { request, error in
guard let results = request.results
as? [VNClassificationObservation]
else { return }
// Output top-3 predictions
for result in results.prefix(3) {
print("\(result.identifier):
\(result.confidence)")
}
}
// Starting image processing
let handler = VNImageRequestHandler(
url: imageURL
)
try? handler.perform([request])
The Swift code loads the MobileNetV2 model through the Vision framework, creates a classification request, and processes the result — an array of VNClassificationObservation objects with class labels and confidence percentages. The entire pipeline from loading to output takes 5–50 ms depending on the model.
To optimize startup time, Core ML compiles the model on first use. Precompiled model reduces cold start from 2–3 seconds to 100–200 ms. It is recommended to compile the model at build time in Xcode, rather than on first app launch. This is especially important for apps with multiple ML models — for example, object detection + classification + NLP.
Core ML and ML Kit solve similar on-device ML tasks but target different ecosystems. Core ML is deeply integrated with Apple Silicon and supports only Apple platforms. Google’s ML Kit is a cross-platform solution for Android and iOS.
| Feature | Core ML | ML Kit |
|---|---|---|
| Platforms | iOS, macOS, watchOS, tvOS | Android, iOS |
| Built-in APIs | Via Vision, Natural Language | 15+ built-in APIs |
| Custom Models | .mlpackage (PyTorch, TF) | TFLite (via adapter) |
| Hardware Acceleration | ANE, GPU, CPU | GPU (Android), CPU |
| Ease of Start | Requires model conversion | Ready APIs without Data Science |
| Performance | 2–50 ms (ANE) | 80–200 ms (CPU/GPU) |
Choose Core ML if your ecosystem is exclusively Apple and you need maximum performance through ANE. If cross-platform support or ready-to-use APIs without conversion are required, ML Kit is more practical.
In practice, many projects use both frameworks: iOS Core ML for high performance, and ML Kit or TensorFlow Lite on Android. A unified PyTorch model is converted to .mlpackage for Apple and to .tflite for Android, allowing consistent ML feature quality on both platforms. This approach requires slightly more DevOps effort but provides maximum audience coverage.
When choosing between Core ML and alternatives, consider development cost: Core ML requires less integration code (3–5 lines of Swift vs 15–20 lines with TFLite) but requires a Mac and Xcode for building. ML Kit, on the other hand, works on any platform but delivers lower performance on iOS due to lack of access to the Apple Neural Engine.
Frequently Asked Questions
iOS 11+ for basic models, iOS 14+ for .mlpackage format. Apple Neural Engine requires an A12 Bionic chip or newer. Core ML supports all iPhone, iPad, and Mac models from 2017 onward.
Yes, via the coremltools tool. TensorFlow models are converted to .mlpackage with preserved accuracy. Supported formats include TensorFlow 2.x, SavedModel, H5, and Frozen Graph.
.mlpackage is a modern container format, structured as a directory with metadata, a binary MLProgram file, and resources. It is 2–3 times more compact than the old .mlmodel and supports quantization.
All computations are performed strictly on device. Core ML does not send data to Apple servers. The framework works in airplane mode and does not require internet connectivity for inference.
Swift is the primary language for integrating Core ML into iOS/macOS apps. Python is used for model conversion via coremltools. Objective-C is also supported for backward compatibility.
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also