Bringing Swift to the Apple ][
Porting Swift to the Apple II
By Yeo Kheng Meng — Maker, Coder, Private Pilot, and Retrocomputing Enthusiast Date: June 25, 2026 | Read Time: minutes
Swift is the powerhouse language driving modern Apple ecosystems. I wondered: could a taste of this modern syntax be brought back to Apple's origins? Specifically, the Apple II, the company's first mass-market hit released in 1977, powered by a 1 MHz MOS 6502 CPU.
The result is SwiftII, a specialized, Swift-flavored development environment designed for the original Apple II through the IIe.
A Note on Process: I'll be honest—this was built in my spare time with significant assistance from AI. I intend to be transparent about that workflow later, as the intersection of LLMs and retro-coding was just as fascinating as the project itself.
The Scope of SwiftII
It is impossible to fit the entire Swift standard library into such a limited machine. Therefore, SwiftII is a full-scale deliberate subset of the language. It is closer in philosophy to Embedded Swift than the massive SDKs used for macOS or iOS.
My primary objectives were:
- Ensure the code looks and feels like Swift at a glance.
- Maintain a high-quality developer experience (DX).
- Implement a functional interpreter.
- Build supporting tools (launcher, file selector, and text editor) to bypass Apple II hardware limitations.
🗺️ Project Roadmap
Because this is an extensive deep dive, here is a guide to the technical sections:
| Category | Key Topics Covered |
|---|---|
| The Basics | Motivation, Target Hardware, Language Features |
| Technical Constraints | The 40,704-byte limit, Memory Banking, 64K+ RAM |
| The Pipeline | Compilation flow, Bytecode structure, Binary families |
| The UX | REPL behavior, Keyboard digraphs, Display issues |
| The Tooling | File browser, Text editor, Disk distribution (9x disks) |
| The Process | AI collaboration, Claude vs. Codex, Documentation |
🖥️ The Application
Upon booting the correct disk, you are greeted by a launcher. From here, you can access:
- An interactive REPL (Read-Eval-Print Loop).
- A file browser to execute
.swiftprograms directly from disk. - A built-in full-screen editor.
Visuals and Demos
The project is fully functional on an original Apple II Plus. Because the II Plus keyboard lacks lowercase letters and the \ key, the system utilizes digraphs for input.
Featured Capabilities:
xsnake: A playable "light-cycle" style game.xgrdemo: A showcase of lo-res color graphics usinggr,color, andvlin.- Full-screen editing (optimized for the IIe 80-column display).
GitHub Repository: https://github.com/yeokm1/swiftii
💡 Motivation
Having previously squeezed a ChatGPT client into DOS and a Slack client into Windows 3.1, I wanted to see if I could port a modern language to vintage silicon.
I looked back to 1979 and Apple Pascal, which utilized the UCSD p-System. Instead of compiling directly to 6502 machine code, it used a Virtual Machine (VM) to execute bytecode. I adopted a similar architecture for SwiftII:
By avoiding native code generation, I could implement a REPL—a staple of the modern Swift SDK—allowing users to test logic interactively.
🛠️ Target Hardware
The baseline is the 1977 Apple II. If it works there, it works everywhere. My specific testbed is an Apple II Plus with the following specs:
- CPU: MOS 6502 @
- RAM:
- 48 KB Main RAM
- Clone Saturn 128K card (acting as a 16K Language Card)
- Total Addressable:
- Video: Clone Videx Videoterm (80-column support)
- Storage: Yellowstone universal disk controller Floppy Emu
- OS: ProDOS 2.4.3 (The modern ProDOS 8 revival)
Hardware Compatibility Note:
The original 1977 model is supported provided it has 48 KB RAM and a 16 KB language card. On machines without Autostart, use C600G or PR#6. The Apple IIe is highly recommended for a better experience due to its native lowercase and ASCII keyboard.
CPU Architecture Detail
The MOS 6502 is an 8-bit processor. Its primary registers are:
A(Accumulator): 8-bitX(Index): 8-bitY(Index): 8-bit
⚙️ Technical Implementation (Preview)
The system operates by transforming human-readable Swift into a compact bytecode.
Example of the conceptual logic flow:
// SwiftII Source
let x = 10
print(x)
[OP_PUSH_CONST 10] [OP_STORE_VAR 0] [OP_LOAD_VAR 0] [OP_CALL_PRINT]
This approach allows the language to exist within the tight constraints of the Apple II's memory map, specifically managing the critical 40,704 bytes available for the core engine.