●TOOLING — Rork's developer repos keep moving: rork-xcode was updated on July 16, rork-device on July 15, and rork-plist on July 13●OPUS46 — Claude Opus 4.6 is live in Rork, and Rork Max is built to assemble apps on top of Claude Code●SIM — A cloud iOS simulator runs in the browser, with one click to install on a device and two clicks to publish to the App Store●MAX — Rork Max emits pure Swift rather than React Native, reaching iPhone, iPad, Apple Watch, Apple TV, Vision Pro, and even iMessage●NATIVE — That opens up HealthKit, ARKit and LiDAR, NFC, Dynamic Island, Live Activities, 3D through Metal, and on-device inference with Core ML●SEED — Rork raised a $15M seed led by Left Lane Capital, with Peak XV and a16z Speedrun joining the round●TOOLING — Rork's developer repos keep moving: rork-xcode was updated on July 16, rork-device on July 15, and rork-plist on July 13●OPUS46 — Claude Opus 4.6 is live in Rork, and Rork Max is built to assemble apps on top of Claude Code●SIM — A cloud iOS simulator runs in the browser, with one click to install on a device and two clicks to publish to the App Store●MAX — Rork Max emits pure Swift rather than React Native, reaching iPhone, iPad, Apple Watch, Apple TV, Vision Pro, and even iMessage●NATIVE — That opens up HealthKit, ARKit and LiDAR, NFC, Dynamic Island, Live Activities, 3D through Metal, and on-device inference with Core ML●SEED — Rork raised a $15M seed led by Left Lane Capital, with Peak XV and a16z Speedrun joining the round
Optimizing Machine Learning in Rork Max Apps — Core ML Integration, Per-Device Tuning, Quantization, Size Reduction
A complete playbook for integrating Core ML into SwiftUI apps generated by Rork Max: model conversion, quantization, Neural Engine targeting, battery management, and per-device tuning — written at the implementation level, not the marketing one.
Build an AI app in Rork Max long enough and you inevitably reach the question: "how do I run this model on-device?" On-device inference removes network dependency, collapses latency, preserves privacy, and kills API costs — four wins at once. For iOS, the shortest path to all of them is Core ML.
Integrating Core ML into a Rork Max SwiftUI project is less linear than it looks. Model conversion, target configuration, Compute Units selection, quantization, battery management, generation-to-generation device differences — each step has landmines, and skipping any of them produces the classic "the model runs, but the app is slow / unstable / drains the battery" symptom. Apps have been rejected in App Store review specifically for ML-driven battery consumption.
This guide is the playbook I've distilled from shipping my own Rork Max projects with Core ML integration. Not an introduction — an implementation-level walkthrough focused on the pitfalls specific to Rork Max output.
1. The integration pipeline, and what Rork Max handles
Core ML integration has five phases: (1) source or train a model, (2) convert to Core ML format, (3) add to Xcode, (4) call inference from Swift, (5) tune per device. Rork Max covers the scaffolding, but phases 3+ are yours.
Rork Max templates don't pre-wire Core ML integration, so you add the model after generation. That's actually healthier: when you swap models later, nothing in the codebase breaks in surprising ways.
The first step: drop .mlmodel or .mlpackage into the Xcode project. Xcode auto-generates a typed Swift wrapper (<ModelName>.swift) so you call inference with type-safe inputs and outputs rather than dictionaries of strings.
2. Model conversion: PyTorch / TensorFlow → Core ML
Most existing models start as PyTorch or TensorFlow. Convert with coremltools.
Three details matter here. convert_to="mlprogram" is the modern format (Xcode 13+) and outpaces the legacy NeuralNetwork format in both speed and flexibility. compute_precision=FLOAT16 halves model size with negligible accuracy loss. minimum_deployment_target=iOS17 unlocks the latest optimizations. If your Rork Max project targets iOS 17+, match it here.
✦
Thank you for reading this far.
Continue Reading
What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.
WHAT YOU'LL LEARN
✦The correct procedure for adding Core ML models to Rork Max SwiftUI output, and the build-time gotchas to avoid
✦How to choose between float16 / int8 / palettization quantization, and size-target the right model for each iPhone generation
✦Concrete patterns for pinning inference to Neural Engine, throttling under thermal pressure, and managing battery impact
Secure payment via Stripe · Cancel anytime
✦
Unlock This Article
Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.
On-device ML makes model size a product decision. App Store binaries have a 4GB uncompressed ceiling, and a 200MB model turns every update into a large download.
Three options in practice:
Float16: Half the size. Essentially no accuracy loss. Default.
Int8: Quarter the size. 1–3% accuracy loss in some tasks. Fine for image classification, ask questions for generative work.
Palettization: 1/8 or smaller, the current best option. Available iOS 17+. Weights are quantized to a limited set of "colors" (8–256). Remarkable compression with minimal accuracy drop.
Concrete measurement from my own project: a MobileNetV3-equivalent image classifier went from 22MB to 3.5MB with palettization, accuracy drop under 1%. It's my default in 2026.
4. Compute Units — making sure Neural Engine actually runs
Apple Silicon devices have three inference paths: CPU, GPU, Neural Engine (ANE). Core ML auto-selects, but doesn't always land on ANE, and ANE is the fastest path by a wide margin.
Explicitly:
import CoreMLlet config = MLModelConfiguration()config.computeUnits = .all // All three (default)// .cpuOnly// .cpuAndGPU// .cpuAndNeuralEngine // Prefer ANE
When a Rork Max-built app feels slow, the cause is almost always "ANE isn't actually handling the work." Verify with Xcode Instruments → Core ML template during development. Do this once per model.
5. Image preprocessing — push it into the model
Preprocessing is a hot path. If you resize, normalize, and channel-convert in Swift for every frame, the CPU burns cycles that should be idle.
Fold preprocessing into the model itself. Specify ct.ImageType during conversion with the right scale and reshape, and Core ML handles it internally. Swift code then passes CVPixelBuffer straight in.
// Good: pass CVPixelBuffer directlylet input = MyModelInput(input: pixelBuffer)let output = try model.prediction(input: input)// Bad: preprocess in Swift first// (CPU-heavy per frame)
6. Battery management
On-device inference costs energy. Continuous inference drains batteries fast, and App Store review has flagged apps for this. Three controls:
Gate inference on intent. Don't run every frame; run when the user acts (shutter, tap). If continuous inference is genuinely needed, drop from 30fps to 10fps — often invisible to users, dramatic in power draw.
Respect Low Power Mode. Check ProcessInfo.processInfo.isLowPowerModeEnabled and widen intervals or swap to a smaller model when it's on.
Throttle on thermal state.ProcessInfo.processInfo.thermalState at .serious or .critical means stop inferring briefly. Preempts OS-level throttling and keeps sustained performance higher.
7. Per-device performance
Neural Engine improves roughly 2× per generation. Model that's slow on an iPhone 12 can be completely fine on iPhone 15.
Rough 2026 targets:
iPhone 12 and earlier: lightweight models (<3MB, ~224×224 input)
iPhone 13–15: mid-range (~20MB, ~384×384)
iPhone 16+: larger (~100MB, 512×512+)
Rork Max projects targeting iOS 17+ on newer devices can tolerate large models. Still plan a fallback model for older hardware.
8. Multiple models and memory management
If your app uses more than one model, memory becomes the constraint. Loaded Core ML models easily consume hundreds of MB; stack a few and jetsam (iOS's low-memory kill) comes for you.
This single pattern cut my peak memory to about a third and effectively eliminated crash-on-old-devices reports.
9. A/B testing and over-the-air model updates
Core ML models ship in the app binary by default, which means updating a model means a new release. Apple's compileModel API breaks that — compile a downloaded model at runtime.
let compiledUrl = try MLModel.compileModel(at: downloadedMlpackageUrl)let model = try MLModel(contentsOf: compiledUrl)
With this, you can serve models from your backend and switch at runtime — A/B tests, per-user personalization, rapid iteration without App Store review. Surface a clean download-and-compile UX (progress indicator, background compile) and users won't notice it happening.
10. Debugging and profiling
Static analysis isn't reliable for Core ML performance. Measure on device.
Xcode Instruments has a Core ML template that visualizes per-inference latency, the actual Compute Unit used, and memory impact. Measurement rules: Release build, Low Power Mode off, app running alone (other foreground apps skew the numbers).
Priorities and principles
Distilling the above into a priority list for Rork Max + Core ML:
First: shrink the model. Binary size, download time, launch latency, memory — all downstream of model size. Palettization is the highest-leverage technique available in 2026; start there.
Second: verify ANE usage. Instruments will tell you whether your model is actually running on Neural Engine. If not, revisit conversion options — convert_to="mlprogram" and minimum_deployment_target usually fix it.
Third: manage battery and heat. This is what keeps you out of App Store rejection and makes your app feel native.
Rork Max generates beautiful SwiftUI. Pair it with a well-optimized Core ML model and you get an iOS app that holds its own against any hand-built native app — often better, because you got to the optimization work faster. Next time you're wiring up a model, walk the ten sections in order. Each one compounds.
Share
Thank You for Reading
Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.