SwiftBrowser#
Run SwiftUI apps in the browser, so you can build and iterate on iOS apps without a Mac for most of the day.
An app's source imports SwiftUI and compiles unchanged for both iOS and the
browser. On Apple platforms it uses Apple's SwiftUI. In the browser it compiles
to WebAssembly against the API-compatible shim in Sources/SwiftUI, which turns
the view tree into render ops that a small TypeScript renderer draws inside an
iPhone frame, or full screen on a phone.
npx @swiftbrowser/cli doctor --install # Swift 6.4's wasm SDK and wasm-opt
npx @swiftbrowser/cli check ~/Projects/MyApp # what the app imports, and a fast compile against the shim
npx @swiftbrowser/cli dev ~/Projects/MyApp # http://localhost:5173, rebuilds on save
npx @swiftbrowser/cli build ~/Projects/MyApp # ./dist: a static site to deploy anywhere
Eighteen of the nineteen Hacking with SwiftUI projects run from their Xcode
projects without a change, and so does a trimmed version of Apple's Food Truck
sample (Examples/FoodTruck).
Documentation#
For app developers:
- Getting started: from an Xcode project to a deployed site.
- CLI reference: commands,
swiftbrowser.json, Foundation, frameworks, Core ML, Swift packages. - Compatibility: the SwiftUI, SwiftData and framework APIs the browser build supports.
@swiftbrowser/xcodeproj: the Xcode project reader, usable on its own.
How it works:
- Architecture and the ops protocol between Swift and the renderer.
- The web renderer and its dev server.
- History: what each development phase added.
Working on SwiftBrowser itself: CONTRIBUTING.md (local development, CI, deploying the examples, releasing to npm, repository layout).
All of it is also published at https://swiftbrowser-docs.pages.dev
(DocsSite/), where every page, or the whole site at
once, can be copied as Markdown.
Packages#
| Package | What it is |
|---|---|
@swiftbrowser/cli |
doctor, check, dev and build for an Xcode project or a folder of Swift sources |
@swiftbrowser/web |
the renderer, the dev server and the static site build |
@swiftbrowser/xcodeproj |
a dependency-free project.pbxproj reader |
@swiftbrowser/swift |
the Swift package (the SwiftUI shim, Charts, SwiftData, FoundationBridge and the framework stand-ins) the CLI builds against |