You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-5Lines changed: 23 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -66,11 +66,11 @@ import SwiftCrossUI
66
66
importDefaultBackend
67
67
68
68
@main
69
-
structCounterApp: App {
69
+
structYourApp: App {
70
70
@Statevar count =0
71
71
72
72
var body: some Scene {
73
-
WindowGroup("CounterApp") {
73
+
WindowGroup("YourApp") {
74
74
HStack {
75
75
Button("-") { count -=1 }
76
76
Text("Count: \(count)")
@@ -80,16 +80,34 @@ struct CounterApp: App {
80
80
}
81
81
}
82
82
```
83
+
Figure 2: *Sources/YourApp/YourApp.swift*
83
84
84
-
Clone the SwiftCrossUI repository to test out this example, and many more;
85
+
## More examples
86
+
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).
88
+
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.
90
+
91
+
To install Swift Bundler, follow [its official installation instructions](https://github.com/stackotter/swift-bundler?tab=readme-ov-file#installation-).
# 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"
90
103
```
91
104
92
-
The documentation contains [a detailed list of all examples](https://stackotter.github.io/swift-cross-ui/documentation/swiftcrossui/examples)
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.
Copy file name to clipboardExpand all lines: Sources/SwiftCrossUI/SwiftCrossUI.docc/Examples.md
+29-6Lines changed: 29 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -9,22 +9,45 @@ A few examples are included with SwiftCrossUI to demonstrate some of its basic f
9
9
-`CounterExample`, a simple app with buttons to increase and decrease a count.
10
10
-`RandomNumberGeneratorExample`, a simple app to generate random numbers between a minimum and maximum.
11
11
-`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.
13
14
-`GreetingGeneratorExample`, a simple app demonstrating dynamic state and the ``ForEach`` view.
14
15
-`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.
16
17
-`StressTestExample`, an app used to test view update performance.
17
18
-`SpreadsheetExample`, an app showcasing tables.
18
19
-`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.
19
23
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
21
25
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-).
# 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"
24
40
```
25
41
26
42
If you want to try out an example with a backend other than the default, you can do that too;
27
43
44
+
```sh
45
+
SCUI_DEFAULT_BACKEND=Gtk3Backend swift-bundler run ExampleToRun
28
46
```
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.
0 commit comments