@@ -13,56 +13,73 @@ already automated with `carton`.
13
13
14
14
### System Requirements
15
15
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/ )
18
17
19
18
### Installation
20
19
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:
23
21
24
- ``` sh
25
- brew install swiftwasm/tap/carton
26
22
```
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
38
24
```
39
25
40
- If you had ` carton ` installed before this, make sure you have version 0.6.1 or greater :
26
+ 2 . Initialize the project :
41
27
42
28
```
43
- carton --version
29
+ swift package init --type executable
44
30
```
45
31
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
+ )
50
52
```
51
53
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
+ }
56
73
```
57
74
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
59
76
during development:
60
77
61
78
```
62
- carton dev
79
+ swift run carton dev
63
80
```
64
81
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
66
83
running. You can edit the app source code in your favorite editor and save it, ` carton `
67
84
will immediately rebuild the app and reload all browser tabs that have the app open.
68
85
0 commit comments