Skip to content

Commit d62a56a

Browse files
committed
Update example running instructions in readme and docs (recommend sbun)
1 parent 80a42a4 commit d62a56a

File tree

2 files changed

+44
-37
lines changed

2 files changed

+44
-37
lines changed

README.md

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ import SwiftCrossUI
6666
import DefaultBackend
6767

6868
@main
69-
struct CounterApp: App {
69+
struct YourApp: App {
7070
@State var count = 0
7171

7272
var body: some Scene {
73-
WindowGroup("CounterApp") {
73+
WindowGroup("YourApp") {
7474
HStack {
7575
Button("-") { count -= 1 }
7676
Text("Count: \(count)")
@@ -80,51 +80,35 @@ struct CounterApp: App {
8080
}
8181
}
8282
```
83+
Figure 2: *Sources/YourApp/YourApp.swift*
8384

84-
Clone the SwiftCrossUI repository to test out this example and others. Running the examples requires an installation of [Swift Bundler](https://github.com/stackotter/swift-bundler), which provides consistent behavior across platforms and enables running on iOS and tvOS simulators and devices.
85+
## More examples
8586

86-
To install Swift Bundler, you can follow [its official installation instructions](https://github.com/stackotter/swift-bundler?tab=readme-ov-file#installation-). Swift Bundler is typically installed using [Mint](https://github.com/yonaskolb/Mint?tab=readme-ov-file#installing), a Swift package manager that lets you easily install and run CLI tools distributed as Swift packages.
87+
The SwiftCrossUI repository contains the above example and many more. The documentation hosts [a detailed list of all examples](https://stackotter.github.io/swift-cross-ui/documentation/swiftcrossui/examples).
8788

88-
If you don't have Mint installed, you can install it with [Homebrew](https://brew.sh/):
89+
Running the examples requires [Swift Bundler](https://github.com/stackotter/swift-bundler), which provides consistent behavior across platforms and enables running on iOS/tvOS devices and simulators.
8990

90-
```sh
91-
brew install mint
92-
```
93-
94-
Then use Mint to install Swift Bundler:
95-
96-
```sh
97-
mint install stackotter/swift-bundler@main
98-
```
99-
100-
Once installed, clone the project and run the example:
91+
To install Swift Bundler, follow [its official installation instructions](https://github.com/stackotter/swift-bundler?tab=readme-ov-file#installation-).
10192

10293
```sh
10394
git clone https://github.com/stackotter/swift-cross-ui
10495
cd swift-cross-ui/Examples
105-
swift bundler run CounterExample
106-
```
107-
108-
You can also run on iOS and tvOS:
109-
110-
```sh
111-
# On a connected device with "iPhone" in its name (macOS only)
112-
swift bundler run CounterExample device iPhone
11396

114-
# On a simulator with "iPhone 16" in its name (macOS only)
115-
swift bundler run CounterExample simulator "iPhone 16"
97+
# Run on host machine
98+
swift-bundler run CounterExample
99+
# Run on a connected device with "iPhone" in its name (macOS only)
100+
swift-bundler run CounterExample --device iPhone
101+
# Run on a simulator with "iPhone 16" in its name (macOS only)
102+
swift-bundler run CounterExample --simulator "iPhone 16"
116103
```
117104

118-
These examples may also be run on your host machine without Swift Bundler by using SwiftPM:
105+
These examples may also be run using SwiftPM. However, resources may not be loaded as expected, and features such as deep linking may not work. You also won't be able to run the examples on iOS or tvOS using this method.
119106

120107
```sh
108+
# Non-recommended method
121109
swift run CounterExample
122110
```
123111

124-
However, resources may not be loaded as expected, and features like deep linking may not work. This method also does not support running on iOS or tvOS.
125-
126-
The documentation contains [a detailed list of all examples](https://stackotter.github.io/swift-cross-ui/documentation/swiftcrossui/examples)
127-
128112
## Backends
129113

130114
SwiftCrossUI has a variety of backends tailored to different operating systems. The beauty of SwiftCrossUI is that you can write your app once and have it look native everywhere. For this reason I recommend using [DefaultBackend](https://stackotter.github.io/swift-cross-ui/documentation/swiftcrossui/defaultbackend) unless you've got particular constraints.

Sources/SwiftCrossUI/SwiftCrossUI.docc/Examples.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,45 @@ A few examples are included with SwiftCrossUI to demonstrate some of its basic f
99
- `CounterExample`, a simple app with buttons to increase and decrease a count.
1010
- `RandomNumberGeneratorExample`, a simple app to generate random numbers between a minimum and maximum.
1111
- `WindowingExample`, a simple app showcasing how ``WindowGroup`` is used to make multi-window apps and
12-
control the properties of each window.
12+
control the properties of each window. It also demonstrates the use of modals
13+
such as alerts and file pickers.
1314
- `GreetingGeneratorExample`, a simple app demonstrating dynamic state and the ``ForEach`` view.
1415
- `NavigationExample`, an app showcasing ``NavigationStack`` and related concepts.
15-
- `SplitExample`, an app showcasing sidebar-based navigation with multiple levels.
16+
- `SplitExample`, an app showcasing ``NavigationSplitView``-based hierarchical navigation.
1617
- `StressTestExample`, an app used to test view update performance.
1718
- `SpreadsheetExample`, an app showcasing tables.
1819
- `ControlsExample`, an app showcasing the various types of controls available.
20+
- `NotesExample`, an app showcasing multi-line text editing and a more realistic usage of SwiftCrossUI.
21+
- `PathsExample`, an app showcasing the use of ``Path`` to draw various shapes.
22+
- `WebViewExample`, an app showcasing the use of ``WebView`` to display websites. Only works on Apple platforms so far.
1923

20-
To run an example, either select the example under schemes at the top of the window (in Xcode), or run it from the command line like so:
24+
## Running examples
2125

22-
```
23-
swift run ExampleToRun
26+
Running the examples requires [Swift Bundler](https://github.com/stackotter/swift-bundler), which provides consistent behavior across platforms and enables running SwiftPM-based apps on iOS/tvOS devices and simulators.
27+
28+
To install Swift Bundler, follow [its official installation instructions](https://github.com/stackotter/swift-bundler?tab=readme-ov-file#installation-).
29+
30+
```sh
31+
git clone https://github.com/stackotter/swift-cross-ui
32+
cd swift-cross-ui/Examples
33+
34+
# Run on host machine
35+
swift-bundler run CounterExample
36+
# Run on a connected device with "iPhone" in its name (macOS only)
37+
swift-bundler run CounterExample --device iPhone
38+
# Run on a simulator with "iPhone 16" in its name (macOS only)
39+
swift-bundler run CounterExample --simulator "iPhone 16"
2440
```
2541

2642
If you want to try out an example with a backend other than the default, you can do that too;
2743

44+
```sh
45+
SCUI_DEFAULT_BACKEND=Gtk3Backend swift-bundler run ExampleToRun
2846
```
29-
SCUI_DEFAULT_BACKEND=QtBackend swift run ExampleToRun
47+
48+
These examples may also be run using SwiftPM. However, resources may not be loaded as expected, and features such as deep linking may not work. You also won't be able to run the examples on iOS or tvOS using this method.
49+
50+
```sh
51+
# Non-recommended method
52+
swift run CounterExample
3053
```

0 commit comments

Comments
 (0)