Core ML — What It Is, Machine Learning Model and How It Works in iOS

Author: IT Sectr Published: 2026-03-26 Reading time: 8 min

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 — Apple’s framework for on-device machine learning across all ecosystem platforms
  • Apple Neural Engine (ANE) provides hardware acceleration for neural networks with performance up to 11 TOPS
  • .mlpackage format combines model, metadata, and configuration in one convenient container
  • Conversion of models from PyTorch and TensorFlow is done via the Python tool coremltools
  • Integration with Vision and Natural Language allows building complex ML pipelines

What Is Core ML?

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.

Key Features

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.

How Core ML Works

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 Model Format

.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

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.

Core ML Performance Comparison

ChipTOPS (ANE)ResNet-50 InferenceYear
A12 Bionic518 ms2018
A14 Bionic119 ms2020
M1 Max224 ms2021
M4 Ultra352 ms2025

Converting Models to Core ML

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 Tool

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.

Conversion Example from PyTorch

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.

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.

Integrating Core ML into an iOS App

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.

Swift Code Example

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.

swift
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 vs ML Kit

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.

FeatureCore MLML Kit
PlatformsiOS, macOS, watchOS, tvOSAndroid, iOS
Built-in APIsVia Vision, Natural Language15+ built-in APIs
Custom Models.mlpackage (PyTorch, TF)TFLite (via adapter)
Hardware AccelerationANE, GPU, CPUGPU (Android), CPU
Ease of StartRequires model conversionReady APIs without Data Science
Performance2–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

What are the minimum requirements for Core ML?

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.

Can I use Core ML with TensorFlow?

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.

How does .mlpackage differ from .mlmodel?

.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.

How does Core ML handle data privacy?

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.

What programming languages does Core ML support?

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

  • Core ML — Apple’s framework for on-device ML across all ecosystem platforms with Apple Neural Engine support
  • .mlpackage — a modern container format combining model, metadata, and resources in a single package
  • Apple Neural Engine provides hardware acceleration for neural networks with performance up to 35 TOPS on M4 Ultra
  • coremltools enables model conversion from PyTorch, TensorFlow, and ONNX in three steps using Python
  • Integration through the Vision framework requires 5–10 lines of Swift code to run a model on an image
  • Inference performance ranges from 2–50 ms depending on the model and chip
  • Data privacy — all computations are strictly local, with no data sent to servers

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.

Discuss the project

Read also