跪拜 Guibai
← All articles
Swift · SwiftUI · Artificial Intelligence

SPI Joins Apple and Swift Drops Its C++ Bootstrapping Requirement

By 东坡肘子 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

A language ecosystem that depends on a single commercial forge for package identity and a C++ compiler for its own toolchain carries structural risk. These two changes reduce that risk and make Swift's cross-platform story more credible.

Summary

Two structural changes landed for Swift in the same week. The Swift Package Index (SPI) joined Apple to build an official package registry, while the Swift project dropped the long-standing requirement that its compiler be buildable with only a C++ host toolchain. SPI's existing discovery, compatibility-checking, and documentation services continue, but the roadmap now points toward trusted package identity, signing, and distribution that reduces the ecosystem's implicit dependency on GitHub. Xcode integration with SPI's search and compatibility data is a natural next step.

On the compiler side, Erik Eckstein announced that building Swift from `main` will require an existing Swift toolchain. This unlocks the ability to rewrite core compiler paths—parser, AST, type checker, mandatory SIL passes—in Swift itself. It is not a full rewrite, but it crosses the threshold into self-hosting: Swift can now enter the compiler's critical path rather than being confined to peripheral tools and optional passes.

Taken together, the two developments address different halves of the same problem. The SPI move tackles package discovery, identity, and trusted distribution. The bootstrapping change improves the toolchain's own maintainability and evolutionary speed. Both are infrastructure bets that matter for Swift's viability beyond Apple's own platforms.

Takeaways
SPI is now part of Apple and will become the foundation of an official Swift package registry.
SPI's existing package discovery, compatibility dashboard, and documentation hosting will continue without disruption.
Package authors do not need to change their current publishing workflows in the near term.
The Swift compiler no longer requires a C++-only host toolchain; building from `main` now needs an existing Swift toolchain.
Core compiler components—parser, AST, type checker, mandatory SIL passes—can now be written in Swift.
SwiftII runs a Swift-style mini development environment on a 1 MHz 6502 Apple II with 64 KB of RAM.
patch-swift compiles Swift functions to WebAssembly and loads new WASM modules at runtime for OTA behavior changes in iOS apps.
SwiftUI's underlying model behaves as a demand-driven attribute graph, not a simple view-tree diff.
A clean-room SwiftUI engine called PureView validates its behavior against real SwiftUI through differential testing.
Intercepting Menu, Picker, and contextMenu display in SwiftUI requires bridging to AppKit's NSMenu.popUpContextMenu.
_UIPortalView, backed by CAPortalLayer, projects a source view's live rendering to another screen location without duplicating the view hierarchy.
New SwiftUI Toolbar APIs include visibilityPriority, ToolbarOverflowMenu, .topBarPinnedTrailing, and toolbarMinimizeBehavior.
iOS-Simulator-Camera-Extend feeds Mac camera, desktop, image, video, and QR code sources into the iOS Simulator via DYLD_INSERT_LIBRARIES and AVFoundation swizzling.
Conclusions

SPI joining Apple closes a gap that SwiftPM alone never addressed: trusted package identity and distribution, not just dependency resolution.

Reducing the ecosystem's reliance on GitHub as the implicit source of package identity and hosting is a quiet but significant de-risking move.

Dropping the C++ bootstrapping requirement is less about language vanity and more about lowering the cost of evolving the compiler itself.

Self-hosting is an engineering maturity signal: it means the language, compiler, and build system are robust enough to sustain their own development.

SwiftII on an Apple II is a useful stress test of Swift's design—what survives when you strip away the runtime, the standard library, and modern hardware assumptions.

OTA updates via WebAssembly in iOS apps sit in a legal gray zone under App Store review guidelines, regardless of technical elegance.

The attribute-graph model of SwiftUI explains why View structs feel ephemeral: they are descriptions, not persistent nodes in a retained tree.

Using real SwiftUI as a differential-testing oracle for a clean-room reimplementation is a pattern AI coding agents could adopt to verify their output against black-box frameworks.

SwiftUI's lack of lifecycle hooks for menu and picker presentation forces developers into AppKit/UIKit bridging, which undermines the cross-platform promise.

_UIPortalView's live projection capability is a reminder that many of the most interesting UIKit features remain private API, inaccessible without risk.

The new Toolbar API strikes a rare balance: it adds explicit control without breaking SwiftUI's existing cross-platform adaptive behavior.

iOS-Simulator-Camera-Extend's dual-path design—feeding both the simulator and a macOS virtual camera from the same frame source—is a clever testing multiplier.

Concepts & terms
Swift Package Index (SPI)
A community-run index that tracks Swift packages, checks their compatibility with different platforms and Swift versions, and hosts their documentation. It is now part of Apple and will form the basis of an official package registry.
Bootstrapping / Self-hosting
The ability of a language's compiler to be written in the language itself. A self-hosting compiler no longer depends on another language's toolchain to build, which signals engineering maturity and reduces external dependencies.
SIL (Swift Intermediate Language)
A low-level intermediate representation used inside the Swift compiler. Mandatory SIL passes are optimization and analysis steps that run on every compilation and were previously required to be implemented in C++.
Attribute Graph
A demand-driven dependency graph that SwiftUI uses internally to track state, dependencies, layout, and animations. View structs are transient descriptions; the attribute graph is the persistent engine that drives updates.
WASM / WasmKit
WebAssembly (WASM) is a portable binary instruction format. WasmKit is a Swift library for executing WASM modules, enabling scenarios like running Swift code compiled to WASM inside an iOS app for OTA updates.
_UIPortalView / CAPortalLayer
A private UIKit view backed by a Core Animation layer that projects the live rendered output of a source view to another location on screen, without duplicating the view hierarchy or generating snapshots.
DYLD_INSERT_LIBRARIES
A macOS dynamic linker environment variable that forces a specified dynamic library to be loaded into a process. Used by iOS-Simulator-Camera-Extend to inject camera-hooking code into simulator apps.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗