Skip to content

Repository files navigation

Swift Prism

Swift Prism is a macOS app for exploring how source code becomes a running program. It is built for learning and investigation: you can watch a small teaching language move through a full compiler pipeline, or capture output from a real Swift toolchain installed on your Mac.

https://apps.apple.com/sg/app/compiler-prism/id6782965485

Swift Prism Lab workspace

Lab — source, pipeline map, stage output, and inspector.

Dual mode

Swift Prism uses two modes on purpose. They solve different problems, and the app keeps them clearly separate so results are never mixed up.

Teaching mode (Prism language)

The Prism language is a small language designed for education. It is not Swift. Every compiler stage is open to inspection:

  1. Read source — tokens and structure linked back to the text you wrote
  2. Check meaning — names, types, scopes, and errors
  3. Lower to intermediate form — a simplified internal representation
  4. Optional teaching optimizations — for example folding constants, with a clear before/after record
  5. Lower to bytecode — instructions for Prism’s own virtual machine
  6. Run and step — Trace mode lets you step, rewind, and inspect values

Use teaching mode when you want to learn how a compiler is put together, or to follow a program line by line without installing multiple Swift versions.

Authentic Swift mode (your toolchains)

On macOS, Prism can run a real Swift compiler you already have—typically from Xcode or Swiftly. That path does not reimplement Swift. It records what the real compiler produces:

  • Diagnostics (errors and notes)
  • Frontend structure summaries
  • SIL (Swift Intermediate Language) as text, with function/block inventory, optional ownership/type hints, and loc → source linkage when present
  • Structured LLVM IR and assembly summaries plus raw dumps
  • Diff — line Diff (cached LCS) and structural SIL inventory Diff
  • Optional Mach-O evidence and a representative driver job graph

Dumps are cleaned up where possible (paths, module-cache banners, ordering) so comparisons are more stable. Structure is a summary, not a reimplementation of the Swift type system.

Use authentic mode when you want evidence from the real toolchain—for example comparing two Swift versions, or browsing SIL differences in a visual workspace.

How the modes fit together

Workspace Role
Learn / Library / Forensics Product modes that reshape sidebar defaults
Lab Edit source and inspect the teaching pipeline
Architecture Map of compiler phases (teaching and authentic)
Diff Compare authentic Swift output across toolchains
Trace Step the teaching VM (step / over / out / source / continue)

Teaching results are never presented as “live Swift compilation.” Authentic output is labeled as coming from a real toolchain.

Swift Prism Diff comparing Swift intermediate language across toolchains

Diff — compare real toolchain output (for example SIL) across versions.

Highlights

  • Native macOS app (SwiftUI); teaching path builds for iOS 17+ as well
  • First-run welcome with an honest dual-mode explainer; reopenable anytime
  • Built-in Help Center: searchable topics for concepts, workspaces, toolchains, and what is simulated vs. authentic
  • Always-visible status bar: engine state, diagnostic counts, active stage, and result provenance on every workspace
  • Menu-bar Workspace menu with ⌘1–⌘4 switching; sidebar rows explain what each workspace does, and diagnostics jump to the offending source line
  • Teaching compiler with inspectable stages and a stepable virtual machine
  • Real Swift toolchain capture, multi-toolchain Diff, SIL/LLVM/asm structure
  • Toolchain discovery and optional Swiftly install management
  • Companion CLI (prism-companion watch) for exchange-based host compilation
  • .compileprism document packages for project persistence
  • Clear UI about what is fully inspectable versus raw compiler text

Requirements

  • macOS 14 or later
  • Xcode (or Command Line Tools) for the macOS SDK when using authentic Swift stages
  • Optional: Swiftly for managing Swift toolchains

Build and run

# Run package tests
cd CompilerAtlas
swift test
# Open the app in Xcode (schemes: Prism = macOS, Prism iOS = teacher mode)
open CompilerAtlas.xcodeproj

Or build from the command line:

# macOS app
xcodebuild -project CompilerAtlas.xcodeproj -scheme Prism -configuration Debug build

# iOS teacher-mode app (simulator)
xcodebuild -project CompilerAtlas.xcodeproj -scheme "Prism iOS" \
  -destination 'platform=iOS Simulator,name=iPhone 17 Pro' build

iOS teacher mode

Prism iOS is a self-contained teaching app: the synthetic Prism pipeline only — Lab, Architecture, and Trace. It runs the teaching language (version PrismSemantics.languageVersion, currently 1.1) entirely on-device with no toolchain setup, and every result is labeled Prism · live. The Help Center lists the exact supported language surface and what the pipeline deliberately does not claim.

Project layout

Path Purpose
CompilerAtlas/ Shared Swift package (language, tools, UI library, tests)
CompilerAtlasMac/ macOS application target
CompilerAtlasIOS/ iOS teacher-mode application target (teaching pipeline only)
CompilerAtlas.xcodeproj Xcode project — schemes Prism (macOS) and Prism iOS
docs/images/ Screenshots used in this README
docs/privacy-policy.md Privacy policy
docs/ROADMAP.md Roadmap (completed backlog + residual limits)
docs/sandbox-mas.md Mac App Store sandbox / toolchain access
docs/investigation/ #89581 localization notes
scripts/ci/linux-container-nightly.sh Optional Linux / container nightly lane
LICENSE Dual license terms

Privacy

Swift Prism is designed to keep your work on your machine. See docs/privacy-policy.md.

Contributing

Ideas and pull requests are welcome. Longer-term ideas are listed in docs/ROADMAP.md.

License

See LICENSE for full dual-license terms (noncommercial public use and separate commercial licensing).

About

GUI for refraction of compiler pipeline

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages