buildanything 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +55 -0
- package/README.md +71 -61
- package/agents/ios-app-review-guardian.md +49 -0
- package/agents/ios-foundation-models-specialist.md +46 -0
- package/agents/ios-storekit-specialist.md +52 -0
- package/agents/ios-swift-architect.md +102 -0
- package/agents/ios-swift-search.md +130 -0
- package/agents/ios-swift-ui-design.md +104 -0
- package/commands/build.md +80 -176
- package/commands/fix.md +65 -0
- package/commands/setup.md +73 -0
- package/commands/ux-review.md +63 -0
- package/commands/verify.md +72 -0
- package/hooks/session-start +18 -1
- package/package.json +5 -2
- package/protocols/brainstorm.md +99 -0
- package/protocols/build-fix.md +52 -0
- package/protocols/cleanup.md +54 -0
- package/protocols/design.md +269 -0
- package/protocols/eval-harness.md +61 -0
- package/protocols/fake-data-detector.md +64 -0
- package/protocols/ios-context.md +235 -0
- package/protocols/ios-frameworks-map.md +323 -0
- package/protocols/ios-phase-branches.md +162 -0
- package/protocols/ios-preflight.md +27 -0
- package/protocols/metric-loop.md +93 -0
- package/protocols/planning.md +87 -0
- package/protocols/smoke-test.md +110 -0
- package/protocols/verify.md +67 -0
- package/protocols/web-phase-branches.md +201 -0
- package/skills/ios/_VENDORED.md +60 -0
- package/skills/ios/activitykit/LICENSE +131 -0
- package/skills/ios/activitykit/SKILL.md +505 -0
- package/skills/ios/activitykit/references/activitykit-patterns.md +868 -0
- package/skills/ios/app-intents/LICENSE +131 -0
- package/skills/ios/app-intents/SKILL.md +494 -0
- package/skills/ios/app-intents/references/appintents-advanced.md +1076 -0
- package/skills/ios/apple-on-device-ai/LICENSE +131 -0
- package/skills/ios/apple-on-device-ai/SKILL.md +505 -0
- package/skills/ios/apple-on-device-ai/references/coreml-conversion.md +425 -0
- package/skills/ios/apple-on-device-ai/references/coreml-optimization.md +344 -0
- package/skills/ios/apple-on-device-ai/references/foundation-models.md +508 -0
- package/skills/ios/apple-on-device-ai/references/mlx-swift.md +285 -0
- package/skills/ios/ios-26-platform/SKILL.md +53 -0
- package/skills/ios/ios-26-platform/references/automatic-adoption.md +161 -0
- package/skills/ios/ios-26-platform/references/backward-compat.md +238 -0
- package/skills/ios/ios-26-platform/references/liquid-glass.md +255 -0
- package/skills/ios/ios-26-platform/references/swiftui-apis.md +277 -0
- package/skills/ios/ios-26-platform/references/toolbar-navigation.md +250 -0
- package/skills/ios/ios-bootstrap/SKILL.md +98 -0
- package/skills/ios/ios-bootstrap/references/apple-docs-mcp-config.md +28 -0
- package/skills/ios/ios-bootstrap/references/new-project-dialog.md +41 -0
- package/skills/ios/ios-bootstrap/references/xcode-mcp-config.md +29 -0
- package/skills/ios/ios-debugger-agent/LICENSE +21 -0
- package/skills/ios/ios-debugger-agent/SKILL.md +58 -0
- package/skills/ios/ios-debugger-agent/agents/openai.yaml +4 -0
- package/skills/ios/ios-entitlements-generator/SKILL.md +47 -0
- package/skills/ios/ios-hig/SKILL.md +41 -0
- package/skills/ios/ios-hig/references/accessibility.md +81 -0
- package/skills/ios/ios-hig/references/content.md +142 -0
- package/skills/ios/ios-hig/references/feedback.md +123 -0
- package/skills/ios/ios-hig/references/interaction.md +199 -0
- package/skills/ios/ios-hig/references/performance-platform.md +129 -0
- package/skills/ios/ios-hig/references/privacy-permissions.md +181 -0
- package/skills/ios/ios-hig/references/visual-design.md +84 -0
- package/skills/ios/ios-info-plist-hardening/SKILL.md +130 -0
- package/skills/ios/ios-maestro-flow-author/SKILL.md +68 -0
- package/skills/ios/ios-maestro-flow-author/references/input-and-scroll.yaml +17 -0
- package/skills/ios/ios-maestro-flow-author/references/modal-and-dismiss.yaml +14 -0
- package/skills/ios/ios-maestro-flow-author/references/onboarding-flow.yaml +16 -0
- package/skills/ios/ios-maestro-flow-author/references/tab-navigation.yaml +13 -0
- package/skills/ios/ios-maestro-flow-author/references/tap-and-assert.yaml +9 -0
- package/skills/ios/swift-accessibility/LICENSE +21 -0
- package/skills/ios/swift-accessibility/SKILL.md +371 -0
- package/skills/ios/swift-accessibility/examples/before-after-appkit.md +446 -0
- package/skills/ios/swift-accessibility/examples/before-after-swiftui.md +441 -0
- package/skills/ios/swift-accessibility/examples/before-after-uikit.md +464 -0
- package/skills/ios/swift-accessibility/references/assistive-access.md +441 -0
- package/skills/ios/swift-accessibility/references/display-settings.md +491 -0
- package/skills/ios/swift-accessibility/references/dynamic-type.md +420 -0
- package/skills/ios/swift-accessibility/references/media-accessibility.md +421 -0
- package/skills/ios/swift-accessibility/references/motor-input.md +393 -0
- package/skills/ios/swift-accessibility/references/nutrition-labels.md +362 -0
- package/skills/ios/swift-accessibility/references/platform-specifics.md +515 -0
- package/skills/ios/swift-accessibility/references/semantic-structure.md +585 -0
- package/skills/ios/swift-accessibility/references/testing-auditing.md +507 -0
- package/skills/ios/swift-accessibility/references/voice-control.md +317 -0
- package/skills/ios/swift-accessibility/references/voiceover-swiftui.md +584 -0
- package/skills/ios/swift-accessibility/references/voiceover-uikit.md +519 -0
- package/skills/ios/swift-accessibility/references/wcag-mapping.md +167 -0
- package/skills/ios/swift-accessibility/resources/audit-template.swift +128 -0
- package/skills/ios/swift-accessibility/resources/qa-checklist.md +258 -0
- package/skills/ios/swift-concurrency/LICENSE +21 -0
- package/skills/ios/swift-concurrency/SKILL.md +171 -0
- package/skills/ios/swift-concurrency/references/_index.md +50 -0
- package/skills/ios/swift-concurrency/references/actors.md +660 -0
- package/skills/ios/swift-concurrency/references/async-algorithms.md +847 -0
- package/skills/ios/swift-concurrency/references/async-await-basics.md +266 -0
- package/skills/ios/swift-concurrency/references/async-sequences.md +710 -0
- package/skills/ios/swift-concurrency/references/core-data.md +560 -0
- package/skills/ios/swift-concurrency/references/glossary.md +135 -0
- package/skills/ios/swift-concurrency/references/linting.md +155 -0
- package/skills/ios/swift-concurrency/references/memory-management.md +569 -0
- package/skills/ios/swift-concurrency/references/migration.md +1104 -0
- package/skills/ios/swift-concurrency/references/performance.md +593 -0
- package/skills/ios/swift-concurrency/references/sendable.md +598 -0
- package/skills/ios/swift-concurrency/references/tasks.md +636 -0
- package/skills/ios/swift-concurrency/references/testing.md +592 -0
- package/skills/ios/swift-concurrency/references/threading.md +495 -0
- package/skills/ios/swift-security-expert/LICENSE +21 -0
- package/skills/ios/swift-security-expert/SKILL.md +470 -0
- package/skills/ios/swift-security-expert/references/biometric-authentication.md +565 -0
- package/skills/ios/swift-security-expert/references/certificate-trust.md +592 -0
- package/skills/ios/swift-security-expert/references/common-anti-patterns.md +690 -0
- package/skills/ios/swift-security-expert/references/compliance-owasp-mapping.md +537 -0
- package/skills/ios/swift-security-expert/references/credential-storage-patterns.md +721 -0
- package/skills/ios/swift-security-expert/references/cryptokit-public-key.md +505 -0
- package/skills/ios/swift-security-expert/references/cryptokit-symmetric.md +497 -0
- package/skills/ios/swift-security-expert/references/keychain-access-control.md +508 -0
- package/skills/ios/swift-security-expert/references/keychain-fundamentals.md +596 -0
- package/skills/ios/swift-security-expert/references/keychain-item-classes.md +476 -0
- package/skills/ios/swift-security-expert/references/keychain-sharing.md +458 -0
- package/skills/ios/swift-security-expert/references/migration-legacy-stores.md +727 -0
- package/skills/ios/swift-security-expert/references/secure-enclave.md +539 -0
- package/skills/ios/swift-security-expert/references/testing-security-code.md +781 -0
- package/skills/ios/swift-testing-expert/LICENSE +21 -0
- package/skills/ios/swift-testing-expert/SKILL.md +79 -0
- package/skills/ios/swift-testing-expert/references/_index.md +12 -0
- package/skills/ios/swift-testing-expert/references/async-testing-and-waiting.md +127 -0
- package/skills/ios/swift-testing-expert/references/expectations.md +145 -0
- package/skills/ios/swift-testing-expert/references/fundamentals.md +141 -0
- package/skills/ios/swift-testing-expert/references/migration-from-xctest.md +127 -0
- package/skills/ios/swift-testing-expert/references/parallelization-and-isolation.md +95 -0
- package/skills/ios/swift-testing-expert/references/parameterized-testing.md +284 -0
- package/skills/ios/swift-testing-expert/references/performance-and-best-practices.md +187 -0
- package/skills/ios/swift-testing-expert/references/traits-and-tags.md +114 -0
- package/skills/ios/swift-testing-expert/references/xcode-workflows.md +70 -0
- package/skills/ios/swiftdata-pro/LICENSE +21 -0
- package/skills/ios/swiftdata-pro/SKILL.md +102 -0
- package/skills/ios/swiftdata-pro/agents/openai.yaml +10 -0
- package/skills/ios/swiftdata-pro/assets/swiftdata-pro-icon.png +0 -0
- package/skills/ios/swiftdata-pro/assets/swiftdata-pro-icon.svg +29 -0
- package/skills/ios/swiftdata-pro/references/class-inheritance.md +104 -0
- package/skills/ios/swiftdata-pro/references/cloudkit.md +10 -0
- package/skills/ios/swiftdata-pro/references/core-rules.md +20 -0
- package/skills/ios/swiftdata-pro/references/indexing.md +27 -0
- package/skills/ios/swiftdata-pro/references/predicates.md +73 -0
- package/skills/ios/swiftui-design-principles/AGENTS.md +21 -0
- package/skills/ios/swiftui-design-principles/LICENSE +21 -0
- package/skills/ios/swiftui-design-principles/README.md +41 -0
- package/skills/ios/swiftui-design-principles/SKILL.md +605 -0
- package/skills/ios/swiftui-design-principles/metadata.json +10 -0
- package/skills/ios/swiftui-liquid-glass/LICENSE +21 -0
- package/skills/ios/swiftui-liquid-glass/SKILL.md +95 -0
- package/skills/ios/swiftui-liquid-glass/agents/openai.yaml +4 -0
- package/skills/ios/swiftui-liquid-glass/references/liquid-glass.md +280 -0
- package/skills/ios/swiftui-performance-audit/LICENSE +21 -0
- package/skills/ios/swiftui-performance-audit/SKILL.md +111 -0
- package/skills/ios/swiftui-performance-audit/agents/openai.yaml +4 -0
- package/skills/ios/swiftui-performance-audit/references/code-smells.md +150 -0
- package/skills/ios/swiftui-performance-audit/references/demystify-swiftui-performance-wwdc23.md +46 -0
- package/skills/ios/swiftui-performance-audit/references/optimizing-swiftui-performance-instruments.md +29 -0
- package/skills/ios/swiftui-performance-audit/references/profiling-intake.md +44 -0
- package/skills/ios/swiftui-performance-audit/references/report-template.md +47 -0
- package/skills/ios/swiftui-performance-audit/references/understanding-hangs-in-your-app.md +33 -0
- package/skills/ios/swiftui-performance-audit/references/understanding-improving-swiftui-performance.md +52 -0
- package/skills/ios/swiftui-pro/LICENSE +21 -0
- package/skills/ios/swiftui-pro/SKILL.md +108 -0
- package/skills/ios/swiftui-pro/agents/openai.yaml +10 -0
- package/skills/ios/swiftui-pro/assets/swiftui-pro-icon.png +0 -0
- package/skills/ios/swiftui-pro/assets/swiftui-pro-icon.svg +29 -0
- package/skills/ios/swiftui-pro/references/accessibility.md +13 -0
- package/skills/ios/swiftui-pro/references/api.md +39 -0
- package/skills/ios/swiftui-pro/references/data.md +43 -0
- package/skills/ios/swiftui-pro/references/design.md +31 -0
- package/skills/ios/swiftui-pro/references/hygiene.md +9 -0
- package/skills/ios/swiftui-pro/references/navigation.md +14 -0
- package/skills/ios/swiftui-pro/references/performance.md +46 -0
- package/skills/ios/swiftui-pro/references/swift.md +56 -0
- package/skills/ios/swiftui-pro/references/views.md +35 -0
- package/skills/ios/swiftui-ui-patterns/LICENSE +21 -0
- package/skills/ios/swiftui-ui-patterns/SKILL.md +100 -0
- package/skills/ios/swiftui-ui-patterns/agents/openai.yaml +4 -0
- package/skills/ios/swiftui-ui-patterns/references/app-wiring.md +201 -0
- package/skills/ios/swiftui-ui-patterns/references/async-state.md +96 -0
- package/skills/ios/swiftui-ui-patterns/references/components-index.md +50 -0
- package/skills/ios/swiftui-ui-patterns/references/controls.md +57 -0
- package/skills/ios/swiftui-ui-patterns/references/deeplinks.md +66 -0
- package/skills/ios/swiftui-ui-patterns/references/focus.md +90 -0
- package/skills/ios/swiftui-ui-patterns/references/form.md +97 -0
- package/skills/ios/swiftui-ui-patterns/references/grids.md +71 -0
- package/skills/ios/swiftui-ui-patterns/references/haptics.md +71 -0
- package/skills/ios/swiftui-ui-patterns/references/input-toolbar.md +51 -0
- package/skills/ios/swiftui-ui-patterns/references/lightweight-clients.md +93 -0
- package/skills/ios/swiftui-ui-patterns/references/list.md +86 -0
- package/skills/ios/swiftui-ui-patterns/references/loading-placeholders.md +38 -0
- package/skills/ios/swiftui-ui-patterns/references/macos-settings.md +71 -0
- package/skills/ios/swiftui-ui-patterns/references/matched-transitions.md +59 -0
- package/skills/ios/swiftui-ui-patterns/references/media.md +73 -0
- package/skills/ios/swiftui-ui-patterns/references/menu-bar.md +101 -0
- package/skills/ios/swiftui-ui-patterns/references/navigationstack.md +159 -0
- package/skills/ios/swiftui-ui-patterns/references/overlay.md +45 -0
- package/skills/ios/swiftui-ui-patterns/references/performance.md +62 -0
- package/skills/ios/swiftui-ui-patterns/references/previews.md +48 -0
- package/skills/ios/swiftui-ui-patterns/references/scroll-reveal.md +133 -0
- package/skills/ios/swiftui-ui-patterns/references/scrollview.md +87 -0
- package/skills/ios/swiftui-ui-patterns/references/searchable.md +71 -0
- package/skills/ios/swiftui-ui-patterns/references/sheets.md +155 -0
- package/skills/ios/swiftui-ui-patterns/references/split-views.md +72 -0
- package/skills/ios/swiftui-ui-patterns/references/tabview.md +114 -0
- package/skills/ios/swiftui-ui-patterns/references/theming.md +71 -0
- package/skills/ios/swiftui-ui-patterns/references/title-menus.md +93 -0
- package/skills/ios/swiftui-ui-patterns/references/top-bar.md +49 -0
- package/skills/ios/swiftui-view-refactor/LICENSE +21 -0
- package/skills/ios/swiftui-view-refactor/SKILL.md +207 -0
- package/skills/ios/swiftui-view-refactor/agents/openai.yaml +4 -0
- package/skills/ios/swiftui-view-refactor/references/mv-patterns.md +161 -0
- package/skills/ios/widgetkit/LICENSE +131 -0
- package/skills/ios/widgetkit/SKILL.md +502 -0
- package/skills/ios/widgetkit/references/widgetkit-advanced.md +871 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
Required Notice: Copyright (c) 2025 dpearson2699 (https://github.com/dpearson2699)
|
|
2
|
+
|
|
3
|
+
# PolyForm Perimeter License 1.0.0
|
|
4
|
+
|
|
5
|
+
<https://polyformproject.org/licenses/perimeter/1.0.0>
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
In order to get any license under these terms, you must agree
|
|
10
|
+
to them as both strict obligations and conditions to all
|
|
11
|
+
your licenses.
|
|
12
|
+
|
|
13
|
+
## Copyright License
|
|
14
|
+
|
|
15
|
+
The licensor grants you a copyright license for the
|
|
16
|
+
software to do everything you might do with the software
|
|
17
|
+
that would otherwise infringe the licensor's copyright
|
|
18
|
+
in it for any permitted purpose. However, you may
|
|
19
|
+
only distribute the software according to [Distribution
|
|
20
|
+
License](#distribution-license) and make changes or new works
|
|
21
|
+
based on the software according to [Changes and New Works
|
|
22
|
+
License](#changes-and-new-works-license).
|
|
23
|
+
|
|
24
|
+
## Distribution License
|
|
25
|
+
|
|
26
|
+
The licensor grants you an additional copyright license
|
|
27
|
+
to distribute copies of the software. Your license
|
|
28
|
+
to distribute covers distributing the software with
|
|
29
|
+
changes and new works permitted by [Changes and New Works
|
|
30
|
+
License](#changes-and-new-works-license).
|
|
31
|
+
|
|
32
|
+
## Notices
|
|
33
|
+
|
|
34
|
+
You must ensure that anyone who gets a copy of any part of
|
|
35
|
+
the software from you also gets a copy of these terms or the
|
|
36
|
+
URL for them above, as well as copies of any plain-text lines
|
|
37
|
+
beginning with `Required Notice:` that the licensor provided
|
|
38
|
+
with the software. For example:
|
|
39
|
+
|
|
40
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
41
|
+
|
|
42
|
+
## Changes and New Works License
|
|
43
|
+
|
|
44
|
+
The licensor grants you an additional copyright license to
|
|
45
|
+
make changes and new works based on the software for any
|
|
46
|
+
permitted purpose.
|
|
47
|
+
|
|
48
|
+
## Patent License
|
|
49
|
+
|
|
50
|
+
The licensor grants you a patent license for the software that
|
|
51
|
+
covers patent claims the licensor can license, or becomes able
|
|
52
|
+
to license, that you would infringe by using the software.
|
|
53
|
+
|
|
54
|
+
## Noncompete
|
|
55
|
+
|
|
56
|
+
Any purpose is a permitted purpose, except for providing to
|
|
57
|
+
others any product that competes with the software.
|
|
58
|
+
|
|
59
|
+
## Competition
|
|
60
|
+
|
|
61
|
+
If you use this software to market a product as a substitute
|
|
62
|
+
for the functionality or value of the software, it competes
|
|
63
|
+
with the software. A product may compete regardless how it is
|
|
64
|
+
designed or deployed. For example, a product may compete even
|
|
65
|
+
if it provides its functionality via any kind of interface
|
|
66
|
+
(including services, libraries or plug-ins), even if it is
|
|
67
|
+
ported to a different platforms or programming languages,
|
|
68
|
+
and even if it is provided free of charge.
|
|
69
|
+
|
|
70
|
+
## Fair Use
|
|
71
|
+
|
|
72
|
+
You may have "fair use" rights for the software under the
|
|
73
|
+
law. These terms do not limit them.
|
|
74
|
+
|
|
75
|
+
## No Other Rights
|
|
76
|
+
|
|
77
|
+
These terms do not allow you to sublicense or transfer any of
|
|
78
|
+
your licenses to anyone else, or prevent the licensor from
|
|
79
|
+
granting licenses to anyone else. These terms do not imply
|
|
80
|
+
any other licenses.
|
|
81
|
+
|
|
82
|
+
## Patent Defense
|
|
83
|
+
|
|
84
|
+
If you make any written claim that the software infringes or
|
|
85
|
+
contributes to infringement of any patent, your patent license
|
|
86
|
+
for the software granted under these terms ends immediately. If
|
|
87
|
+
your company makes such a claim, your patent license ends
|
|
88
|
+
immediately for work on behalf of your company.
|
|
89
|
+
|
|
90
|
+
## Violations
|
|
91
|
+
|
|
92
|
+
The first time you are notified in writing that you have
|
|
93
|
+
violated any of these terms, or done anything with the software
|
|
94
|
+
not covered by your licenses, your licenses can nonetheless
|
|
95
|
+
continue if you come into full compliance with these terms,
|
|
96
|
+
and take practical steps to correct past violations, within
|
|
97
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
98
|
+
end immediately.
|
|
99
|
+
|
|
100
|
+
## No Liability
|
|
101
|
+
|
|
102
|
+
***As far as the law allows, the software comes as is, without
|
|
103
|
+
any warranty or condition, and the licensor will not be liable
|
|
104
|
+
to you for any damages arising out of these terms or the use
|
|
105
|
+
or nature of the software, under any kind of legal claim.***
|
|
106
|
+
|
|
107
|
+
## Definitions
|
|
108
|
+
|
|
109
|
+
The **licensor** is the individual or entity offering these
|
|
110
|
+
terms, and the **software** is the software the licensor makes
|
|
111
|
+
available under these terms.
|
|
112
|
+
|
|
113
|
+
A **product** can be a good or service, or a combination
|
|
114
|
+
of them.
|
|
115
|
+
|
|
116
|
+
**You** refers to the individual or entity agreeing to these
|
|
117
|
+
terms.
|
|
118
|
+
|
|
119
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
120
|
+
or other kind of organization that you work for, plus all
|
|
121
|
+
organizations that have control over, are under the control of,
|
|
122
|
+
or are under common control with that organization. **Control**
|
|
123
|
+
means ownership of substantially all the assets of an entity,
|
|
124
|
+
or the power to direct its management and policies by vote,
|
|
125
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
126
|
+
|
|
127
|
+
**Your licenses** are all the licenses granted to you for the
|
|
128
|
+
software under these terms.
|
|
129
|
+
|
|
130
|
+
**Use** means anything you do with the software requiring one
|
|
131
|
+
of your licenses.
|
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: apple-on-device-ai
|
|
3
|
+
description: "Integrate on-device AI using Foundation Models framework, Core ML, and open-source LLM runtimes on Apple Silicon. Covers Foundation Models (LanguageModelSession, @Generable, @Guide, SystemLanguageModel, structured output, tool calling), Core ML (coremltools, model conversion, quantization, palettization, pruning, Neural Engine, MLTensor), MLX Swift (transformer inference, unified memory), and llama.cpp (GGUF, cross-platform LLM). Use when building tool-calling AI features, working with guided generation schemas, converting models, or running on-device inference."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# On-Device AI for Apple Platforms
|
|
7
|
+
|
|
8
|
+
Guide for selecting, deploying, and optimizing on-device ML models. Covers Apple
|
|
9
|
+
Foundation Models, Core ML, MLX Swift, and llama.cpp.
|
|
10
|
+
|
|
11
|
+
## Contents
|
|
12
|
+
|
|
13
|
+
- [Framework Selection Router](#framework-selection-router)
|
|
14
|
+
- [Apple Foundation Models Overview](#apple-foundation-models-overview)
|
|
15
|
+
- [Core ML Overview](#core-ml-overview)
|
|
16
|
+
- [MLX Swift Overview](#mlx-swift-overview)
|
|
17
|
+
- [Multi-Backend Architecture](#multi-backend-architecture)
|
|
18
|
+
- [Performance Best Practices](#performance-best-practices)
|
|
19
|
+
- [Common Mistakes](#common-mistakes)
|
|
20
|
+
- [Review Checklist](#review-checklist)
|
|
21
|
+
- [References](#references)
|
|
22
|
+
|
|
23
|
+
## Framework Selection Router
|
|
24
|
+
|
|
25
|
+
Use this decision tree to pick the right framework for your use case.
|
|
26
|
+
|
|
27
|
+
### Apple Foundation Models
|
|
28
|
+
|
|
29
|
+
**When to use:** Text generation, summarization, entity extraction, structured
|
|
30
|
+
output, and short dialog on iOS 26+ / macOS 26+ devices with Apple Intelligence
|
|
31
|
+
enabled. Zero setup -- no API keys, no network, no model downloads.
|
|
32
|
+
|
|
33
|
+
**Best for:**
|
|
34
|
+
- Generating text or structured data with `@Generable` types
|
|
35
|
+
- Summarization, classification, content tagging
|
|
36
|
+
- Tool-augmented generation with the `Tool` protocol
|
|
37
|
+
- Apps that need guaranteed on-device privacy
|
|
38
|
+
|
|
39
|
+
**Not suited for:** Complex math, code generation, factual accuracy tasks,
|
|
40
|
+
or apps targeting pre-iOS 26 devices.
|
|
41
|
+
|
|
42
|
+
### Core ML
|
|
43
|
+
|
|
44
|
+
**When to use:** Deploying custom trained models (vision, NLP, audio) across all
|
|
45
|
+
Apple platforms. Converting models from PyTorch, TensorFlow, or scikit-learn
|
|
46
|
+
with coremltools.
|
|
47
|
+
|
|
48
|
+
**Best for:**
|
|
49
|
+
- Image classification, object detection, segmentation
|
|
50
|
+
- Custom NLP classifiers, sentiment analysis models
|
|
51
|
+
- Audio/speech models via SoundAnalysis integration
|
|
52
|
+
- Any scenario needing Neural Engine optimization
|
|
53
|
+
- Models requiring quantization, palettization, or pruning
|
|
54
|
+
|
|
55
|
+
### MLX Swift
|
|
56
|
+
|
|
57
|
+
**When to use:** Running specific open-source LLMs (Llama, Mistral, Qwen, Gemma)
|
|
58
|
+
on Apple Silicon with maximum throughput. Research and prototyping.
|
|
59
|
+
|
|
60
|
+
**Best for:**
|
|
61
|
+
- Highest sustained token generation on Apple Silicon
|
|
62
|
+
- Running Hugging Face models from `mlx-community`
|
|
63
|
+
- Research requiring automatic differentiation
|
|
64
|
+
- Fine-tuning workflows on Mac
|
|
65
|
+
|
|
66
|
+
### llama.cpp
|
|
67
|
+
|
|
68
|
+
**When to use:** Cross-platform LLM inference using GGUF model format. Production
|
|
69
|
+
deployments needing broad device support.
|
|
70
|
+
|
|
71
|
+
**Best for:**
|
|
72
|
+
- GGUF quantized models (Q4_K_M, Q5_K_M, Q8_0)
|
|
73
|
+
- Cross-platform apps (iOS + Android + desktop)
|
|
74
|
+
- Maximum compatibility with open-source model ecosystem
|
|
75
|
+
|
|
76
|
+
### Quick Reference
|
|
77
|
+
|
|
78
|
+
| Scenario | Framework |
|
|
79
|
+
|---|---|
|
|
80
|
+
| Text generation, zero setup (iOS 26+) | Foundation Models |
|
|
81
|
+
| Structured output from on-device LLM | Foundation Models (`@Generable`) |
|
|
82
|
+
| Image classification, object detection | Core ML |
|
|
83
|
+
| Custom model from PyTorch/TensorFlow | Core ML + coremltools |
|
|
84
|
+
| Running specific open-source LLMs | MLX Swift or llama.cpp |
|
|
85
|
+
| Maximum throughput on Apple Silicon | MLX Swift |
|
|
86
|
+
| Cross-platform LLM inference | llama.cpp |
|
|
87
|
+
| OCR and text recognition | Vision framework |
|
|
88
|
+
| Sentiment analysis, NER, tokenization | Natural Language framework |
|
|
89
|
+
| Training custom classifiers on device | Create ML |
|
|
90
|
+
|
|
91
|
+
## Apple Foundation Models Overview
|
|
92
|
+
|
|
93
|
+
On-device language model optimized for Apple Silicon. Available on devices
|
|
94
|
+
supporting Apple Intelligence (iOS 26+, macOS 26+).
|
|
95
|
+
|
|
96
|
+
- Token budget covers input + output; check `contextSize` for the limit
|
|
97
|
+
- Check `supportedLanguages` for supported locales
|
|
98
|
+
- Guardrails always enforced, cannot be disabled
|
|
99
|
+
|
|
100
|
+
### Availability Checking (Required)
|
|
101
|
+
|
|
102
|
+
Always check before using. Never crash on unavailability.
|
|
103
|
+
|
|
104
|
+
```swift
|
|
105
|
+
import FoundationModels
|
|
106
|
+
|
|
107
|
+
switch SystemLanguageModel.default.availability {
|
|
108
|
+
case .available:
|
|
109
|
+
// Proceed with model usage
|
|
110
|
+
case .unavailable(.appleIntelligenceNotEnabled):
|
|
111
|
+
// Guide user to enable Apple Intelligence in Settings
|
|
112
|
+
case .unavailable(.modelNotReady):
|
|
113
|
+
// Model is downloading; show loading state
|
|
114
|
+
case .unavailable(.deviceNotEligible):
|
|
115
|
+
// Device cannot run Apple Intelligence; use fallback
|
|
116
|
+
default:
|
|
117
|
+
// Graceful fallback for any other reason
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Session Management
|
|
122
|
+
|
|
123
|
+
```swift
|
|
124
|
+
// Basic session
|
|
125
|
+
let session = LanguageModelSession()
|
|
126
|
+
|
|
127
|
+
// Session with instructions
|
|
128
|
+
let session = LanguageModelSession {
|
|
129
|
+
"You are a helpful cooking assistant."
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Session with tools
|
|
133
|
+
let session = LanguageModelSession(
|
|
134
|
+
tools: [weatherTool, recipeTool]
|
|
135
|
+
) {
|
|
136
|
+
"You are a helpful assistant with access to tools."
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Key rules:
|
|
141
|
+
- Sessions are stateful -- multi-turn conversations maintain context automatically
|
|
142
|
+
- One request at a time per session (check `session.isResponding`)
|
|
143
|
+
- Call `session.prewarm()` before user interaction for faster first response
|
|
144
|
+
- Save/restore transcripts: `LanguageModelSession(model: model, tools: [], transcript: savedTranscript)`
|
|
145
|
+
|
|
146
|
+
### Structured Output with @Generable
|
|
147
|
+
|
|
148
|
+
The `@Generable` macro creates compile-time schemas for type-safe output:
|
|
149
|
+
|
|
150
|
+
```swift
|
|
151
|
+
@Generable
|
|
152
|
+
struct Recipe {
|
|
153
|
+
@Guide(description: "The recipe name")
|
|
154
|
+
var name: String
|
|
155
|
+
|
|
156
|
+
@Guide(description: "Cooking steps", .count(3))
|
|
157
|
+
var steps: [String]
|
|
158
|
+
|
|
159
|
+
@Guide(description: "Prep time in minutes", .range(1...120))
|
|
160
|
+
var prepTime: Int
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let response = try await session.respond(
|
|
164
|
+
to: "Suggest a quick pasta recipe",
|
|
165
|
+
generating: Recipe.self
|
|
166
|
+
)
|
|
167
|
+
print(response.content.name)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### @Guide Constraints
|
|
171
|
+
|
|
172
|
+
| Constraint | Purpose |
|
|
173
|
+
|---|---|
|
|
174
|
+
| `description:` | Natural language hint for generation |
|
|
175
|
+
| `.anyOf([values])` | Restrict to enumerated string values |
|
|
176
|
+
| `.count(n)` | Fixed array length |
|
|
177
|
+
| `.range(min...max)` | Numeric range |
|
|
178
|
+
| `.minimum(n)` / `.maximum(n)` | One-sided numeric bound |
|
|
179
|
+
| `.minimumCount(n)` / `.maximumCount(n)` | Array length bounds |
|
|
180
|
+
| `.constant(value)` | Always returns this value |
|
|
181
|
+
| `.pattern(regex)` | String format enforcement |
|
|
182
|
+
| `.element(guide)` | Guide applied to each array element |
|
|
183
|
+
|
|
184
|
+
Properties generate in declaration order. Place foundational data before
|
|
185
|
+
dependent data for better results.
|
|
186
|
+
|
|
187
|
+
### Streaming Structured Output
|
|
188
|
+
|
|
189
|
+
```swift
|
|
190
|
+
let stream = session.streamResponse(
|
|
191
|
+
to: "Suggest a recipe",
|
|
192
|
+
generating: Recipe.self
|
|
193
|
+
)
|
|
194
|
+
for try await snapshot in stream {
|
|
195
|
+
// snapshot.content is Recipe.PartiallyGenerated (all properties optional)
|
|
196
|
+
if let name = snapshot.content.name { updateNameLabel(name) }
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Tool Calling
|
|
201
|
+
|
|
202
|
+
```swift
|
|
203
|
+
struct WeatherTool: Tool {
|
|
204
|
+
let name = "weather"
|
|
205
|
+
let description = "Get current weather for a city."
|
|
206
|
+
|
|
207
|
+
@Generable
|
|
208
|
+
struct Arguments {
|
|
209
|
+
@Guide(description: "The city name")
|
|
210
|
+
var city: String
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
func call(arguments: Arguments) async throws -> String {
|
|
214
|
+
let weather = try await fetchWeather(arguments.city)
|
|
215
|
+
return weather.description
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Register tools at session creation. The model invokes them autonomously.
|
|
221
|
+
|
|
222
|
+
### Error Handling
|
|
223
|
+
|
|
224
|
+
```swift
|
|
225
|
+
do {
|
|
226
|
+
let response = try await session.respond(to: prompt)
|
|
227
|
+
} catch let error as LanguageModelSession.GenerationError {
|
|
228
|
+
switch error {
|
|
229
|
+
case .guardrailViolation(let context):
|
|
230
|
+
// Content triggered safety filters
|
|
231
|
+
case .exceededContextWindowSize(let context):
|
|
232
|
+
// Too many tokens; summarize and retry
|
|
233
|
+
case .concurrentRequests(let context):
|
|
234
|
+
// Another request is in progress on this session
|
|
235
|
+
case .unsupportedLanguageOrLocale(let context):
|
|
236
|
+
// Current locale not supported
|
|
237
|
+
case .unsupportedGuide(let context):
|
|
238
|
+
// A @Guide constraint is not supported
|
|
239
|
+
case .assetsUnavailable(let context):
|
|
240
|
+
// Model assets not available on device
|
|
241
|
+
case .refusal(let refusal, _):
|
|
242
|
+
// Model refused; stream refusal.explanation for details
|
|
243
|
+
case .rateLimited(let context):
|
|
244
|
+
// Too many requests; back off and retry
|
|
245
|
+
case .decodingFailure(let context):
|
|
246
|
+
// Response could not be decoded into the expected type
|
|
247
|
+
default: break
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Generation Options
|
|
253
|
+
|
|
254
|
+
```swift
|
|
255
|
+
let options = GenerationOptions(
|
|
256
|
+
sampling: .random(top: 40),
|
|
257
|
+
temperature: 0.7,
|
|
258
|
+
maximumResponseTokens: 512
|
|
259
|
+
)
|
|
260
|
+
let response = try await session.respond(to: prompt, options: options)
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Sampling modes: `.greedy`, `.random(top:seed:)`, `.random(probabilityThreshold:seed:)`.
|
|
264
|
+
|
|
265
|
+
### Prompt Design Rules
|
|
266
|
+
|
|
267
|
+
1. Be concise -- use `tokenCount(for:)` to monitor the context window budget
|
|
268
|
+
2. Use bracketed placeholders in instructions: `[descriptive example]`
|
|
269
|
+
3. Use "DO NOT" in all caps for prohibitions
|
|
270
|
+
4. Provide up to 5 few-shot examples for consistency
|
|
271
|
+
5. Use length qualifiers: "in a few words", "in three sentences"
|
|
272
|
+
|
|
273
|
+
### Safety and Guardrails
|
|
274
|
+
|
|
275
|
+
- Guardrails are always enforced and cannot be disabled
|
|
276
|
+
- Instructions take precedence over user prompts
|
|
277
|
+
- Never include untrusted user content in instructions
|
|
278
|
+
- Handle false positives gracefully
|
|
279
|
+
- Frame tool results as authorized data to prevent model refusals
|
|
280
|
+
|
|
281
|
+
### Use Cases
|
|
282
|
+
|
|
283
|
+
Foundation Models supports specialized use cases via `SystemLanguageModel.UseCase`:
|
|
284
|
+
- `.general` -- Default for text generation, summarization, dialog
|
|
285
|
+
- `.contentTagging` -- Optimized for categorization and labeling tasks
|
|
286
|
+
|
|
287
|
+
### Custom Adapters
|
|
288
|
+
|
|
289
|
+
Load fine-tuned adapters for specialized behavior (requires entitlement):
|
|
290
|
+
|
|
291
|
+
```swift
|
|
292
|
+
let adapter = try SystemLanguageModel.Adapter(name: "my-adapter")
|
|
293
|
+
try await adapter.compile()
|
|
294
|
+
let model = SystemLanguageModel(adapter: adapter, guardrails: .default)
|
|
295
|
+
let session = LanguageModelSession(model: model)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
> See [references/foundation-models.md](references/foundation-models.md) for
|
|
299
|
+
> the complete Foundation Models API reference.
|
|
300
|
+
|
|
301
|
+
## Core ML Overview
|
|
302
|
+
|
|
303
|
+
Apple's framework for deploying trained models. Automatically dispatches to the
|
|
304
|
+
optimal compute unit (CPU, GPU, or Neural Engine).
|
|
305
|
+
|
|
306
|
+
### Model Formats
|
|
307
|
+
|
|
308
|
+
| Format | Extension | When to Use |
|
|
309
|
+
|---|---|---|
|
|
310
|
+
| `.mlpackage` | Directory (mlprogram) | All new models (iOS 15+) |
|
|
311
|
+
| `.mlmodel` | Single file (neuralnetwork) | Legacy only (iOS 11-14) |
|
|
312
|
+
| `.mlmodelc` | Compiled | Pre-compiled for faster loading |
|
|
313
|
+
|
|
314
|
+
Always use mlprogram (`.mlpackage`) for new work.
|
|
315
|
+
|
|
316
|
+
### Conversion Pipeline (coremltools)
|
|
317
|
+
|
|
318
|
+
```python
|
|
319
|
+
import coremltools as ct
|
|
320
|
+
|
|
321
|
+
# PyTorch conversion (torch.jit.trace)
|
|
322
|
+
model.eval() # CRITICAL: always call eval() before tracing
|
|
323
|
+
traced = torch.jit.trace(model, example_input)
|
|
324
|
+
mlmodel = ct.convert(
|
|
325
|
+
traced,
|
|
326
|
+
inputs=[ct.TensorType(shape=(1, 3, 224, 224), name="image")],
|
|
327
|
+
minimum_deployment_target=ct.target.iOS18,
|
|
328
|
+
convert_to='mlprogram',
|
|
329
|
+
)
|
|
330
|
+
mlmodel.save("Model.mlpackage")
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Optimization Techniques
|
|
334
|
+
|
|
335
|
+
| Technique | Size Reduction | Accuracy Impact | Best Compute Unit |
|
|
336
|
+
|---|---|---|---|
|
|
337
|
+
| INT8 per-channel | ~4x | Low | CPU/GPU |
|
|
338
|
+
| INT4 per-block | ~8x | Medium | GPU |
|
|
339
|
+
| Palettization 4-bit | ~8x | Low-Medium | Neural Engine |
|
|
340
|
+
| W8A8 (weights+activations) | ~4x | Low | ANE (A17 Pro/M4+) |
|
|
341
|
+
| Pruning 75% | ~4x | Medium | CPU/ANE |
|
|
342
|
+
|
|
343
|
+
### Swift Integration
|
|
344
|
+
|
|
345
|
+
```swift
|
|
346
|
+
let config = MLModelConfiguration()
|
|
347
|
+
config.computeUnits = .all
|
|
348
|
+
let model = try MLModel(contentsOf: modelURL, configuration: config)
|
|
349
|
+
|
|
350
|
+
// Async prediction (iOS 17+)
|
|
351
|
+
let output = try await model.prediction(from: input)
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### MLTensor (iOS 18+)
|
|
355
|
+
|
|
356
|
+
Swift type for multidimensional array operations:
|
|
357
|
+
|
|
358
|
+
```swift
|
|
359
|
+
import CoreML
|
|
360
|
+
|
|
361
|
+
let tensor = MLTensor([1.0, 2.0, 3.0, 4.0])
|
|
362
|
+
let reshaped = tensor.reshaped(to: [2, 2])
|
|
363
|
+
let result = tensor.softmax()
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
> See [references/coreml-conversion.md](references/coreml-conversion.md) for the
|
|
367
|
+
> full conversion pipeline and [references/coreml-optimization.md](references/coreml-optimization.md)
|
|
368
|
+
> for optimization techniques.
|
|
369
|
+
|
|
370
|
+
## MLX Swift Overview
|
|
371
|
+
|
|
372
|
+
Apple's ML framework for Swift. Highest sustained generation throughput on
|
|
373
|
+
Apple Silicon via unified memory architecture.
|
|
374
|
+
|
|
375
|
+
### Loading and Running LLMs
|
|
376
|
+
|
|
377
|
+
```swift
|
|
378
|
+
import MLX
|
|
379
|
+
import MLXLLM
|
|
380
|
+
|
|
381
|
+
let config = ModelConfiguration(id: "mlx-community/Mistral-7B-Instruct-v0.3-4bit")
|
|
382
|
+
let model = try await LLMModelFactory.shared.loadContainer(configuration: config)
|
|
383
|
+
|
|
384
|
+
try await model.perform { context in
|
|
385
|
+
let input = try await context.processor.prepare(
|
|
386
|
+
input: UserInput(prompt: "Hello")
|
|
387
|
+
)
|
|
388
|
+
let stream = try generate(
|
|
389
|
+
input: input,
|
|
390
|
+
parameters: GenerateParameters(temperature: 0.0),
|
|
391
|
+
context: context
|
|
392
|
+
)
|
|
393
|
+
for await part in stream {
|
|
394
|
+
print(part.chunk ?? "", terminator: "")
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Model Selection by Device
|
|
400
|
+
|
|
401
|
+
| Device | RAM | Recommended Model | RAM Usage |
|
|
402
|
+
|---|---|---|---|
|
|
403
|
+
| iPhone 12-14 | 4-6 GB | SmolLM2-135M or Qwen 2.5 0.5B | ~0.3 GB |
|
|
404
|
+
| iPhone 15 Pro+ | 8 GB | Gemma 3n E4B 4-bit | ~3.5 GB |
|
|
405
|
+
| Mac 8 GB | 8 GB | Llama 3.2 3B 4-bit | ~3 GB |
|
|
406
|
+
| Mac 16 GB+ | 16 GB+ | Mistral 7B 4-bit | ~6 GB |
|
|
407
|
+
|
|
408
|
+
### Memory Management
|
|
409
|
+
|
|
410
|
+
1. Never exceed 60% of total RAM on iOS
|
|
411
|
+
2. Set GPU cache limits: `MLX.GPU.set(cacheLimit: 512 * 1024 * 1024)`
|
|
412
|
+
3. Unload models on app backgrounding
|
|
413
|
+
4. Use "Increased Memory Limit" entitlement for larger models
|
|
414
|
+
5. Physical device required (no simulator support for Metal GPU)
|
|
415
|
+
|
|
416
|
+
> See [references/mlx-swift.md](references/mlx-swift.md) for full MLX Swift
|
|
417
|
+
> patterns and llama.cpp integration.
|
|
418
|
+
|
|
419
|
+
## Multi-Backend Architecture
|
|
420
|
+
|
|
421
|
+
When an app needs multiple AI backends (e.g., Foundation Models + MLX fallback):
|
|
422
|
+
|
|
423
|
+
```swift
|
|
424
|
+
func respond(to prompt: String) async throws -> String {
|
|
425
|
+
if SystemLanguageModel.default.isAvailable {
|
|
426
|
+
return try await foundationModelsRespond(prompt)
|
|
427
|
+
} else if canLoadMLXModel() {
|
|
428
|
+
return try await mlxRespond(prompt)
|
|
429
|
+
} else {
|
|
430
|
+
throw AIError.noBackendAvailable
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Serialize all model access through a coordinator actor to prevent contention:
|
|
436
|
+
|
|
437
|
+
```swift
|
|
438
|
+
actor ModelCoordinator {
|
|
439
|
+
func withExclusiveAccess<T>(_ work: () async throws -> T) async rethrows -> T {
|
|
440
|
+
try await work()
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
## Performance Best Practices
|
|
446
|
+
|
|
447
|
+
1. Run outside debugger for accurate benchmarks (Xcode: Cmd-Opt-R, uncheck
|
|
448
|
+
"Debug Executable")
|
|
449
|
+
2. Call `session.prewarm()` for Foundation Models before user interaction
|
|
450
|
+
3. Pre-compile Core ML models to `.mlmodelc` for faster loading
|
|
451
|
+
4. Use EnumeratedShapes over RangeDim for Neural Engine optimization
|
|
452
|
+
5. Use 4-bit palettization for best Neural Engine memory/latency gains
|
|
453
|
+
6. Batch Vision framework requests in a single `perform()` call
|
|
454
|
+
7. Use async prediction (iOS 17+) in Swift concurrency contexts
|
|
455
|
+
8. Neural Engine (Core ML) is most energy-efficient for compatible operations
|
|
456
|
+
|
|
457
|
+
## Common Mistakes
|
|
458
|
+
|
|
459
|
+
1. **No availability check.** Calling `LanguageModelSession()` without checking
|
|
460
|
+
`SystemLanguageModel.default.availability` crashes on unsupported devices.
|
|
461
|
+
2. **No fallback UI.** Users on pre-iOS 26 or devices without Apple Intelligence
|
|
462
|
+
see nothing. Always provide a graceful degradation path.
|
|
463
|
+
3. **Exceeding the context window.** The token budget covers input + output.
|
|
464
|
+
Monitor usage via `tokenCount(for:)` and summarize when needed.
|
|
465
|
+
4. **Concurrent requests on one session.** `LanguageModelSession` supports one
|
|
466
|
+
request at a time. Check `session.isResponding` or serialize access.
|
|
467
|
+
5. **Untrusted content in instructions.** User input placed in the instructions
|
|
468
|
+
parameter bypasses guardrail boundaries. Keep user content in the prompt.
|
|
469
|
+
6. **Forgetting `model.eval()` before Core ML tracing.** PyTorch models must be
|
|
470
|
+
in eval mode before `torch.jit.trace`. Training-mode artifacts corrupt output.
|
|
471
|
+
7. **Using neuralnetwork format.** Always use `mlprogram` (.mlpackage) for new
|
|
472
|
+
Core ML models. The legacy neuralnetwork format is deprecated.
|
|
473
|
+
8. **Exceeding 60% RAM on iOS (MLX Swift).** Large models cause OOM kills.
|
|
474
|
+
9. **Running MLX in simulator.** MLX requires Metal GPU -- use physical devices.
|
|
475
|
+
10. **Not unloading models on background.** Unload in `scenePhase == .background`.
|
|
476
|
+
|
|
477
|
+
## Review Checklist
|
|
478
|
+
|
|
479
|
+
- [ ] Framework selection matches use case and target OS version
|
|
480
|
+
- [ ] Foundation Models: availability checked before every API call
|
|
481
|
+
- [ ] Foundation Models: graceful fallback when model unavailable
|
|
482
|
+
- [ ] Foundation Models: session prewarm called before user interaction
|
|
483
|
+
- [ ] Foundation Models: @Generable properties in logical generation order
|
|
484
|
+
- [ ] Foundation Models: token budget accounted for (check `contextSize`)
|
|
485
|
+
- [ ] Core ML: model format is mlprogram (.mlpackage) for iOS 15+
|
|
486
|
+
- [ ] Core ML: model.eval() called before tracing/exporting PyTorch models
|
|
487
|
+
- [ ] Core ML: minimum_deployment_target set explicitly
|
|
488
|
+
- [ ] Core ML: model accuracy validated after compression
|
|
489
|
+
- [ ] MLX Swift: model size appropriate for target device RAM
|
|
490
|
+
- [ ] MLX Swift: GPU cache limits set, models unloaded on backgrounding
|
|
491
|
+
- [ ] All model access serialized through coordinator actor
|
|
492
|
+
- [ ] Concurrency: model types and tool implementations are `Sendable`-conformant or `@MainActor`-isolated
|
|
493
|
+
- [ ] Physical device testing performed (not simulator)
|
|
494
|
+
|
|
495
|
+
## References
|
|
496
|
+
|
|
497
|
+
- [Foundation Models API](references/foundation-models.md) -- LanguageModelSession, @Generable, tool calling, prompt design
|
|
498
|
+
- [Core ML Conversion](references/coreml-conversion.md) -- Model conversion from PyTorch, TensorFlow, other frameworks
|
|
499
|
+
- [Core ML Optimization](references/coreml-optimization.md) -- Quantization, palettization, pruning, performance tuning
|
|
500
|
+
- [MLX Swift & llama.cpp](references/mlx-swift.md) -- MLX Swift patterns, llama.cpp integration, memory management
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
---
|
|
504
|
+
|
|
505
|
+
Vendored from: https://github.com/dpearson2699/swift-ios-skills/tree/main/skills/apple-on-device-ai
|