1---2name: ios-ai-ml3description: Use when implementing or reviewing iOS AI and ML features with Apple on-device frameworks, model evaluation, and privacy controls; use ios-architecture for general module boundaries.4metadata:5 portable: true6 compatible_with:7 - claude-code8 - codex9---1011# iOS AI/ML12Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.1314<!-- dual-compat-start -->15## Use When1617- Building or reviewing iOS, iPadOS, or macOS AI/ML features using Foundation Models, Core AI, Core ML, Vision, NaturalLanguage, Speech, SoundAnalysis, Create ML, Evaluations, Private Cloud Compute, or a third-party Language Model provider.18- The work includes on-device inference, custom models, multimodal prompts, agentic model tool use, AI evaluation, model-provider selection, privacy-sensitive AI, or Apple Intelligence availability gates.1920## Do Not Use When2122- The task is plain iOS implementation with no AI/ML path; use `ios-development`.23- The task is AI product architecture outside Apple platforms; use `ai-app-architecture`, `ai-llm-integration`, or `ai-evaluation`.24- The task is only AI security, prompt injection, or action authorization; use this skill with `ios-security-and-rbac`.2526## Required Inputs2728- Feature goal, model/provider choices, target Apple platforms, device/OS floor, privacy constraints, offline expectations, data inputs, tools/actions the model may call, and evaluation criteria.29- Confirm whether the deliverable is design, implementation, migration, review, evaluation plan, or release evidence.3031## Workflow32331. Load `ios-development` for Apple-platform implementation rules and availability policy.342. Load `references/apple-intelligence-stack-wwdc26.md` for Foundation Models, Core AI, provider routing, Evaluations, and availability gates.353. Load `references/skill-deep-dive.md` only when you need legacy Core ML, Vision, NaturalLanguage, Create ML, or model-optimization recipes.364. Choose the lowest-risk model path that solves the task: deterministic API, Core ML/Core AI owned model, on-device Foundation Models, Private Cloud Compute, or third-party provider.375. Define privacy, fallback, telemetry, evaluation, and security gates before writing production code.3839## Quality Standards4041- Every AI feature has a provider boundary, availability gate, privacy path, fallback state, and evaluation set.42- On-device claims must be true: no network dependency unless the code path is explicitly cloud or third-party.43- Agentic or tool-calling model features require authorization, audit logging, and security review.44- Model performance work must include device, latency, memory, battery, and thermal evidence.4546## Anti-Patterns4748- Treating Core ML, Core AI, and Foundation Models as interchangeable.49- Sending sensitive user data to a cloud model because the on-device path was harder.50- Shipping prompt-only tests for model behavior that changes by tool, locale, region, model, or data state.51- Logging prompts, model context, OCR text, tool payloads, or generated sensitive content without a privacy review.5253## Outputs5455- AI feature architecture, provider decision matrix, model integration plan, evaluation suite, privacy/fallback checklist, performance budget, or review findings.5657## Evidence Produced5859| Category | Artifact | Format | Example |60|----------|----------|--------|---------|61| Correctness | AI evaluation plan | Markdown doc covering prompts, providers, tools, unavailable states, and regression cases | `docs/ios/ai-evaluations-checkout.md` |62| Performance | On-device inference budget | Markdown doc covering per-device latency, memory, battery, and thermal budget | `docs/ios/ai-perf-budget.md` |63| Data safety | AI data-flow record | Markdown doc identifying on-device, PCC, third-party, logs, and retention | `docs/ios/ai-data-flow.md` |6465## References6667- `references/apple-intelligence-stack-wwdc26.md` for Foundation Models, Core AI, Evaluations, provider routing, availability gates, and security handoffs.68- `references/skill-deep-dive.md` for Core ML, Vision, NaturalLanguage, Create ML, model updates, optimization, privacy-preserving patterns, and older Apple ML recipes.69<!-- dual-compat-end -->7071## Quick Apple AI Stack Map7273## Inputs7475| Artefact | Produced by | Required? | Why |76|---|---|---|---|77| Use-case and harm definition | Product and security review | required | Bounds model behaviour and prohibited outcomes |78| Representative evaluation set | Domain owner | required | Measures quality on real inputs |79| Device and OS support matrix | `ios-quality-and-release` | required | Selects framework and fallback paths |8081## Decision Rules8283| Constraint | Choice |84|---|---|85| Sensitive input and supported on-device task | On-device framework |86| Unsupported device or unavailable model | Deterministic non-AI fallback |87| Safety-critical or irreversible action | Require human confirmation; AI may only propose |88| Quality cannot be measured on representative data | Stop before release |8990## Capability Contract9192Read and search are required; model downloads, network calls, device execution, and edits require task authority. Never upload private input merely because local inference is unavailable.9394## Domain Anti-Patterns9596- Shipping a demo prompt as an evaluation. Fix: use versioned representative cases and failure thresholds.97- Hiding model unavailability behind a spinner. Fix: expose a deterministic fallback state.98- Letting generated output perform irreversible actions. Fix: validate and confirm structured intent.99- Logging prompts containing personal data. Fix: redact or disable payload logging.100- Claiming support from simulator results alone. Fix: test the declared physical-device matrix.101102| Layer | Use For |103| --- | --- |104| Foundation Models | LLM-backed app features using Apple Foundation Models, PCC, Claude, Gemini, or another Language Model provider. |105| Core AI | Bring-your-own model runtime on Apple Silicon, on-device. |106| Core ML | Packaged or downloaded `.mlmodel` inference, typed wrappers, batch prediction, classic ML. |107| Vision | OCR, barcode, image analysis, camera understanding, and model-callable visual tools. |108| NaturalLanguage | Deterministic language tagging/classification when an LLM is not needed. |109| Speech/SoundAnalysis/Music Understanding | Audio transcription, classification, and local audio understanding. |