Machine Learning (Core ML) Development for iOS Apps
Why Core ML Instead of Cloud Inference?
Convert a model from a Python environment to mobile production and immediately face format incompatibility, inference latency, and no update mechanism without an App Store release. Core ML solves these problems natively – but only if properly embedded into the app architecture. We have completed over 50 Core ML integrations and guarantee stable operation on devices starting from iPhone 8. On-device inference eliminates network delays and preserves user data privacy. For more details on Core ML capabilities, see the official Apple documentation.
How to Avoid Common Core ML Integration Mistakes
The most common mistake is converting a model without considering the target hardware. coremltools allows you to specify minimum_deployment_target and compute unit type: cpuOnly, cpuAndGPU, cpuAndNeuralEngine. If you omit cpuAndNeuralEngine for A12+, the model will not run on the Neural Engine and will execute on CPU, which is 5–10 times slower for convolutional networks. Our engineers are Apple-certified and always choose the optimal configuration.
A second issue is the input format. Core ML expects a CVPixelBuffer with a specific kCVPixelFormatType. If the app receives UIImage from camera via AVCapturePhotoOutput, you need an intermediate conversion through CIImage → CVPixelBuffer. Doing this on the main thread is a sure way to dropped frames. The entire capture and inference chain should run on DispatchQueue with .userInteractive QoS or via the Vision framework, which manages buffers itself.
Vision + CoreML is the right combination for most tasks: VNCoreMLRequest handles scaling, normalization, and buffer management. But if you need sequential inference on a video stream, use VNSequenceRequestHandler – it caches state between frames.
How We Guarantee Inference Speed
We start with an audit of the source model: format (ONNX, TensorFlow SavedModel, PyTorch TorchScript), weight size, number of operations. For conversion we use coremltools 7.x, for quantized models – ct.optimize.coreml with LinearQuantizer or PalettizationConfig. 8-bit quantization reduces model size by 4x without noticeable accuracy loss on most classifiers.
Example from practice: a fintech client wanted document forgery detection on-device. The original TFLite model (MobileNetV3, 12 MB) took 280 ms on iPhone 12. After conversion to .mlpackage with computeUnits = .cpuAndNeuralEngine and Float16 compression – 34 ms on the same device. Additionally, we wrapped the inference in MLModelConfiguration with allowLowPrecisionAccumulationOnGPU = true. Server infrastructure savings reached up to 70%.
| Parameter | Before Optimization | After Optimization |
|---|---|---|
| Model size | 12 MB | 3 MB (Float16) |
| Inference time | 280 ms | 34 ms |
| Processor used | CPU | Neural Engine |
Data from the official Apple Core ML Optimization Guide sample If you want similar optimization, contact us for an audit of your model.
Conversion Technical Details
Beyond quantization, we apply pruning and profiling via Xcode Instruments (Core ML Instrument). For models with dynamic input sizes, we use MLMultiArrayConstraint with shapeFlexibility. The entire ML layer is isolated in a separate Swift Package with the MLInferenceService protocol.
What Does Model Quantization Provide?
8-bit quantization using LinearQuantizer reduces model size by 4x and speeds up inference up to 2x on supported hardware. For classification tasks, accuracy drops less than 1%. If maximum accuracy is needed, we use half-precision (Float16) – size reduces by half with no accuracy loss. Our experience shows that most models can be safely quantized to 8-bit.
How We Update Models Without a Release
To update models without a release, we set up downloading via CloudKit or a custom S3-compatible storage. MLModel(contentsOf:) accepts a local URL – the model is downloaded in the background, verified by SHA-256, and atomically replaced using FileManager.replaceItem. The old version is kept as a fallback.
Architecturally, the entire ML layer is isolated into a separate module (Swift Package) with the MLInferenceService protocol. This allows swapping implementations in tests and reusing across multiple targets.
What Is Included in the Work
- Audit of the source model and selection of conversion path.
- Conversion to
.mlmodel/.mlpackageviacoremltools. - Optimization: quantization, pruning, compute unit selection.
- Integration via
Visionor directMLModelAPI. - Setup of OTA model updates (CloudKit / S3).
- Unit tests of inference with reference inputs/outputs.
- Profiling via Xcode Instruments (Core ML Instrument).
Get a consultation on Core ML integration today. Contact us for an audit of your model – we will calculate timelines and cost.
Timeline
Integration of a ready converted model into an existing app – from 3 to 5 business days. If conversion, optimization, and OTA update setup from scratch are needed – 1–2 weeks. Cost is calculated individually after analysis of requirements and the source model.







