Skip to content

Commit 3baaabe

Browse files
Update browser app instructions
1 parent 54d735e commit 3baaabe

File tree

2 files changed

+48
-31
lines changed

2 files changed

+48
-31
lines changed

src/getting-started/browser-app.md

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,73 @@ already automated with `carton`.
1313

1414
### System Requirements
1515

16-
- macOS 10.15 and Xcode 11.4 or later.
17-
- [Swift 5.2 or later](https://swift.org/download/) and Ubuntu 18.04 for Linux users.
16+
- [Swift 5.9.2 or later](https://swift.org/download/)
1817

1918
### Installation
2019

21-
On macOS `carton` can be installed with [Homebrew](https://brew.sh/). Make sure you have Homebrew
22-
installed and then run:
20+
1. Create a directory for your project and make it current:
2321

24-
```sh
25-
brew install swiftwasm/tap/carton
2622
```
27-
28-
You'll have to build `carton` from sources on Linux. Clone the repository and run
29-
`swift build -c release`, the `carton` binary will be located in the `.build/release`
30-
directory after that.
31-
Assuming you already have Homebrew installed, you can create a new Tokamak
32-
app by following these steps:
33-
34-
1. Install `carton`:
35-
36-
```
37-
brew install swiftwasm/tap/carton
23+
mkdir MyApp && cd MyApp
3824
```
3925

40-
If you had `carton` installed before this, make sure you have version 0.6.1 or greater:
26+
2. Initialize the project:
4127

4228
```
43-
carton --version
29+
swift package init --type executable
4430
```
4531

46-
2. Create a directory for your project and make it current:
47-
48-
```
49-
mkdir TokamakApp && cd TokamakApp
32+
3. Add Tokamak and carton as dependencies to your `Package.swift`:
33+
34+
```swift
35+
// swift-tools-version:5.8
36+
import PackageDescription
37+
let package = Package(
38+
name: "MyApp",
39+
platforms: [.macOS(.v11), .iOS(.v13)],
40+
dependencies: [
41+
.package(url: "https://github.com/TokamakUI/Tokamak", from: "0.11.0"),
42+
.package(url: "https://github.com/swiftwasm/carton", from: "1.0.0"),
43+
],
44+
targets: [
45+
.executableTarget(
46+
name: "MyApp",
47+
dependencies: [
48+
.product(name: "TokamakShim", package: "Tokamak")
49+
]),
50+
]
51+
)
5052
```
5153

52-
3. Initialize the project from a template with `carton`:
53-
54-
```
55-
carton init --template tokamak
54+
4. Add your first view to `Sources/main.swift`:
55+
56+
```swift
57+
import TokamakDOM
58+
59+
@main
60+
struct TokamakApp: App {
61+
var body: some Scene {
62+
WindowGroup("Tokamak App") {
63+
ContentView()
64+
}
65+
}
66+
}
67+
68+
struct ContentView: View {
69+
var body: some View {
70+
Text("Hello, world!")
71+
}
72+
}
5673
```
5774

58-
4. Build the project and start the development server, `carton dev` can be kept running
75+
5. Build the project and start the development server, `swift run carton dev` can be kept running
5976
during development:
6077

6178
```
62-
carton dev
79+
swift run carton dev
6380
```
6481

65-
5. Open [http://127.0.0.1:8080/](http://127.0.0.1:8080/) in your browser to see the app
82+
6. Open [http://127.0.0.1:8080/](http://127.0.0.1:8080/) in your browser to see the app
6683
running. You can edit the app source code in your favorite editor and save it, `carton`
6784
will immediately rebuild the app and reload all browser tabs that have the app open.
6885

src/getting-started/testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ subdirectory when you build in release mode.
8181
## Building and running the test suite with `carton`
8282

8383
If you use [`carton`](https://carton.dev) to develop and build your app, as described in [our guide
84-
for browser apps](./browser-app.md), just run `carton test` in the
84+
for browser apps](./browser-app.md), just run `swift run carton test` in the
8585
root directory of your package. This will automatically build the test suite and run it with a WASI runtime for you.

0 commit comments

Comments
 (0)