---
title: "Set up Xcode and MLX Swift"
lesson_id: "02"
---

# Set up Xcode and MLX Swift

- **Lesson ID:** 02
- **Goal:** Set up Xcode 27, add mlx-swift and mlx-swift-lm, and state Mac vs Simulator vs device honestly.
- **Human lesson:** [02-set-up-xcode-and-mlx-swift.html](02-set-up-xcode-and-mlx-swift.html)

## Prerequisites

- An Apple silicon Mac.
- Xcode 27 available, matching the iOS 27 / macOS 27 era used on Edge FDE.

## Inputs, outputs, and artifacts

- **Inputs:** A new SwiftUI App target.
- **Outputs:** Resolved packages and a successful empty-app build.
- **Artifacts:** Language-tagged bash for toolchain checks, plus a Package.swift sketch.

## Agent build steps

1. Put Environment setup first. Xcode 27. iOS 27 or macOS 27. Metal Toolchain if prompted.
2. Show bash for `xcode-select --install` and `xcodebuild -version`.
3. Add `https://github.com/ml-explore/mlx-swift` and `https://github.com/ml-explore/mlx-swift-lm`. Tell the reader to confirm the current tag.
4. Sketch products `MLXLLM`, `MLXLMCommon`, and `MLXHuggingFace`. Mark the sketch as something to verify.
5. Say Mac can run the GPU, Simulator is compile and UI, a real device is the iOS Metal path.
6. Build the empty app before generate. Link [PyTorch to Core AI in Xcode](../pytorch-core-ai-xcode/) and [Core AI vs Core ML vs MLX](../core-ai-vs-core-ml-vs-mlx/).

## Constraints

Keep the language simple, friendly, and literal. No quizzes, no em dashes, no invented WWDC sessions. Brand Edge FDE only. No generate call in this lesson. Do not invent SPM product names beyond the public mlx-swift-lm README products.

## Key concepts

- Xcode 27 on an Apple silicon Mac. iOS 27 or macOS 27 SwiftUI app.
- Add mlx-swift and mlx-swift-lm. Confirm product names on the tag you pinned.
- Mac can run the GPU. Simulator is compile and UI. A real device is the iOS Metal path.
- Build the empty app before you download weights or write generate.

## Takeaways

- Pin current packages and re-read the README. Do not invent product names.
- Use Simulator for UI. Use a Mac or a device for Metal.
- You now have an environment. The first runnable load is the next lesson.

## Acceptance checks

- Environment setup section appears before package Swift.
- Bash and Swift are language-tagged.
- Mac / Simulator / device split is explicit.
- [ ] Proceed to [lesson 03 brief](03-register-custom-architecture.llms.md).
