What you can ship after this page
- Install Xcode 27 on Apple silicon, open a coding agent from the toolbar, and run
/planbefore it touches the repo. - Write a first on-device summary with Foundation Models’
LanguageModelSession. - Pick the on-device system model, Private Cloud Compute, Core AI / MLX, or a Claude / Gemini package per task.
- Turn the session into an in-app agent with tools and a Dynamic Profile, not another chat window.
- Map region limits, context overflow, and memory pressure to Apple’s docs. These steps are documentation, not a lab run on our machines.
Let Xcode 27 change your project. Put the model in the app with the same Swift API. Do not treat both as one “install AI” click.
Prerequisites: Xcode 27 has to install first
Apple’s Xcode system requirements list Xcode 27 as needing macOS Tahoe 26.6 or later, with the iOS 27 through macOS 27 SDKs. The Xcode 27 release notes say Xcode 27 installs and runs only on Apple silicon. An Intel Mac can remain a user’s device. It cannot be the machine for this tutorial.
The Apple’s June 2026 newsroom post says developer betas for iOS 27, macOS 27, and Xcode 27 were posted on developer.apple.com that day. Apple Intelligence stays region-limited. The list below is boot order, not “newest always wins.”
- Apple silicon Mac on the macOS version the docs name.
- Install Xcode 27 from the developer site with a developer account. Do not aim the iOS 27 SDK at a leftover Xcode 26.
- In System Settings, turn Apple Intelligence on. In unsupported regions the on-device session fails immediately.
- Create or open an iOS or macOS app. Set the deployment target to the APIs you actually call. Do not copy iOS 18 from an old gist.
- Get Cmd+R into a simulator before you open a coding agent or
import FoundationModels.
Memory tiers are a different article. When the assistant boots a simulator, 16GB versus 24GB is a pressure curve — see Which Mac specs Xcode 27 AI coding actually needs. This page only needs: Xcode 27 installs, and the Mac can stay awake.
How to use Xcode 27: coding agent to the first plan
What’s new in Xcode 27 moves the coding agent from a sidebar chat into an editor conversation: splits, tabs, parallel tasks. The toolbar starts a new thread. When you want thinking before edits, use the slash command /plan.
- Open the project, start a coding-agent conversation from the toolbar. It appears as an editor tab, not the old Assistant sidebar.
- Do not lead with “rewrite this app in SwiftUI.” Name the files, the modules that must not move, and how you will check the work (tests or a simulator screenshot).
- Type
/plan. The agent gathers context, may spawn sub-agents, and writes a plan without touching files. Annotate the plan, then allow implementation. - Watch the diff and artifacts (shots, previews) on the right. Release notes say the agent can boot a simulator, install the app, and synthesize touches. You still own Build and Submit.
- Parallel threads show unread state in the coding-assistant sidebar. Do not let two agents edit the same files. Approve one plan at a time.
Xcode 27’s agent knows Swift and Apple frameworks. It is not Foundation Models. It edits your source. The Swift API in the next section is what your users invoke. You can run both: the agent writes, the simulator runs your respond(to:).
A terminal coding agent such as Claude Code is a different host. If you still ship from Xcode, stay in this IDE. Do not let parallel agents edit the same files — see AI agent file isolation best practices.
Foundation Models: the first compiling Swift
Foundation Models framework page defines the framework as a native Swift API for any large language model in your app. The on-device system model, Private Cloud Compute, and third-party packages that conform to the Language Model protocol share one session type. The WWDC26 Apple Intelligence guide adds multimodal image prompts and Vision OCR / barcode tools the model can call.
import FoundationModels
let session = LanguageModelSession(
instructions: "You summarize travel notes in three short sentences."
)
let response = try await session.respond(
to: "Notes: fly to Tokyo at 09:00, then Asakusa."
)
print(response.content)
Put this on a button or an async task, not in a synchronous init. If the module is missing, link FoundationModels on the target and raise the deployment version to what the docs list.
A session is stateful. Each respond(to:) lands in the transcript. Hitting the context limit throws. From iOS 26.4 you can inspect context size and token counts. On overflow, start a new session and, if you must keep continuity, carry instructions plus the last successful reply — the recovery path from Apple’s session talk, not “reboot the app.”
Choosing local AI: on-device, Core AI, MLX, PCC
What’s new in the Foundation Models framework lays out the menu. The on-device system model was rebuilt: better instruction following, images in the prompt. For a larger model, use PrivateCloudComputeLanguageModel (~32K context, reasoning). To run your own weights, use the open-source Core AI or MLX adapters. Claude and Gemini ship Swift packages on the same protocol.
| Path | Use it when | What you pay |
|---|---|---|
| SystemLanguageModel (on-device) | Summaries, labels, short chat, offline, privacy | Device compute and battery; no cloud API bill |
| Private Cloud Compute | Reasoning, longer context, Apple models on watchOS 27 | No cloud API cost for Small Business Program apps under 2 million first-time downloads, per the newsroom post; still request the entitlement |
| Core AI | Your LLM on unified memory and the Neural Engine | Binary size, RAM, heat; no token invoice, hard device ceiling |
| MLX language model | Open models from the MLX-Community on Hugging Face | Download and license; GPU/ANE occupancy |
| Claude / Gemini packages | Frontier cloud models with the same tools and guided generation | Per-token billing; keys in Keychain / OAuth, never in the binary |
PCC uses the same session shape; you swap the model instance. Reasoning depth trades latency. Independent researchers can inspect the “prompts are not stored” claims; that belongs in the PCC session, not this install path.
import FoundationModels
let model = PrivateCloudComputeLanguageModel()
let session = LanguageModelSession(model: model)
let response = try await session.respond(
to: "Propose three origami projects from this journal.",
options: GenerationOptions()
)
print(response.content)
macOS 27 also ships the fm CLI and a Python SDK for the terminal. That is for scripts, not a replacement for the in-app Swift session. When a local model fights Xcode and the simulator for unified memory, read Memory spikes and swap on Apple silicon cloud Mac runners before you keep the weights on the Mac instead of pointing the session at PCC.
In-app AI agents: tools and Dynamic Profiles
The Xcode coding agent edits the repo. An in-app agent is a model plus tools plus swappable instructions. What’s new in the Foundation Models framework uses a crafts journal: analyze photos on-device with a write-back tool, then switch to PCC to brainstorm. Multiple sessions used to be the boilerplate. A Dynamic Profile picks the active instructions, tools, and model inside one session.
Do not start with multi-agent graphs. Accept the work in this order:
- One session, fixed instructions, a working
respond. - One tool you wrote (for example, persist a structured result in SwiftData). The model chooses when to call it. You choose whether the side effect is reversible.
- Add system tools when needed: Vision OCR / barcodes, or Spotlight-backed local retrieval.
- Only then split two modes in a Dynamic Profile: analysis on-device, planning on PCC. One profile is active at a time.
System-wide discovery is a different line: App Intents expose content and actions to Siri and Spotlight — see WWDC 2026: iOS 27, Siri, and Apple Intelligence. This tutorial’s agent stays in your process. Do not grade quality by vibe. The Evaluations framework measures prompt changes. It does not replace unit tests or assertions on tool side effects.
Errors, regions, machines: which layer failed
Split failures into four layers so you do not “fix” a missing Apple Intelligence toggle by swapping models.
- Xcode 27 will not install: OS version or Intel silicon. Read the requirements and notes; do not copy old builds from a forum.
- Session fails immediately: region, model assets still downloading, or deployment target too low. Check Settings, then the availability API.
- Error mid-chat: context window. Catch the overflow, compact the transcript, open a new session.
- The Mac turns sticky: coding agent + simulator + local model on one unified-memory pool. Drop the large local model before you buy SSD. Consider 24GB next.
Third-party cloud models add a bill and keys. Session and response usage reports input, cache hits, and reasoning tokens. Keep secrets out of Git. That is the provider you chose, not a Foundation Models defect.
FAQ
Can I follow this with almost no Swift?
The coding agent can draft Swift. You still have to read the diff, run tests, and refuse file and Keychain tools. If you cannot read Swift, do not wire tools that write files or charge cards.
Does Foundation Models require the network?
The on-device system model is designed to work offline. PCC and Claude / Gemini need a network. “No cloud API cost” in the newsroom post covers eligible PCC use, not every model.
Is Xcode’s coding agent the same as an in-app agent?
No. One edits your source. The other calls models and tools on the user’s device. This tutorial covers both because search queries smash them into one “Apple AI.”
Is PCC really free for a small shop?
The newsroom post and framework page say App Store Small Business Program developers with fewer than two million first-time downloads get next-gen Apple Foundation Models on PCC with no cloud API cost. Quotas, iCloud+ headroom, and the entitlement live in the developer docs. Do not paste that sentence onto a customer price page.
Do I have to buy a new Mac for on-device AI?
You need Apple silicon that can run Xcode 27. You do not have to buy new on day one. 16GB can start; evaluate 24GB if the assistant keeps a simulator up. Run the same project on a cloud Mac you can resize before you lock unified memory at checkout.
Summary
Keep the order: Xcode 27 installs → /plan on the coding agent → one LanguageModelSession → swap on-device / PCC / Core AI per task → tools and a Dynamic Profile. Each step has its own acceptance check. Do not attach three providers on day one.
Coding agents want an Apple silicon Mac that stays awake
Xcode 27’s agent boots simulators and previews. On-device Foundation Models and Core AI share the same unified memory. A laptop lid kills a long plan. kvmboot’s cloud Mac mini is an always-on Apple silicon box for the Xcode 27 project and the first session over SSH. Memory tiers: Which Mac specs Xcode 27 AI coding actually needs.