Skip to content

Commit

Permalink
Disable hot reloading on Windows, and avoid importing SwiftBundlerRun…
Browse files Browse the repository at this point in the history
…time on Windows in examples for now
  • Loading branch information
stackotter committed Jun 17, 2024
1 parent 6f44497 commit c72824c
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 13 deletions.
6 changes: 5 additions & 1 deletion Examples/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ let backend = ProcessInfo.processInfo.environment["SCUI_BACKEND"] ?? "GtkBackend
let exampleDependencies: [Target.Dependency] = [
"SwiftCrossUI",
"SelectedBackend",
.product(name: "SwiftBundlerRuntime", package: "swift-bundler"),
.product(
name: "SwiftBundlerRuntime",
package: "swift-bundler",
condition: .when(platforms: [.macOS, .linux])
),
]

let package = Package(
Expand Down
5 changes: 4 additions & 1 deletion Examples/Sources/ControlsExample/ControlsApp.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import SelectedBackend
import SwiftCrossUI
import SwiftBundlerRuntime

#if canImport(SwiftBundlerRuntime)
import SwiftBundlerRuntime
#endif

class ControlsState: Observable {
@Observed var count = 0
Expand Down
5 changes: 4 additions & 1 deletion Examples/Sources/CounterExample/CounterApp.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import SelectedBackend
import SwiftCrossUI
import SwiftBundlerRuntime

#if canImport(SwiftBundlerRuntime)
import SwiftBundlerRuntime
#endif

class CounterState: Observable {
@Observed var count = 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import SelectedBackend
import SwiftCrossUI
import SwiftBundlerRuntime

#if canImport(SwiftBundlerRuntime)
import SwiftBundlerRuntime
#endif

class GreetingGeneratorState: Observable {
@Observed var name = ""
Expand Down
8 changes: 6 additions & 2 deletions Examples/Sources/NavigationExample/NavigationApp.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Foundation
import SelectedBackend
import SwiftCrossUI
import SwiftBundlerRuntime

#if canImport(SwiftBundlerRuntime)
import SwiftBundlerRuntime
#endif

enum SubjectArea: Codable {
case science
Expand Down Expand Up @@ -45,7 +48,8 @@ struct NavigationApp: App {
Text("Choose a science subject")
.padding(.bottom, 10)

NavigationLink("Physics", value: ScienceSubject.physics, path: state.$path)
NavigationLink(
"Physics", value: ScienceSubject.physics, path: state.$path)
NavigationLink(
"Chemistry", value: ScienceSubject.chemistry, path: state.$path)
case .humanities:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import SelectedBackend
import SwiftCrossUI

#if canImport(SwiftBundlerRuntime)
import SwiftBundlerRuntime
#endif

class RandomNumberGeneratorState: Observable {
@Observed var minNum = 0
@Observed var maxNum = 100
Expand Down
5 changes: 4 additions & 1 deletion Examples/Sources/SplitExample/SplitApp.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Foundation
import SelectedBackend
import SwiftCrossUI
import SwiftBundlerRuntime

#if canImport(SwiftBundlerRuntime)
import SwiftBundlerRuntime
#endif

enum SubjectArea {
case science
Expand Down
5 changes: 4 additions & 1 deletion Examples/Sources/SpreadsheetExample/SpreadsheetApp.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import SelectedBackend
import SwiftCrossUI
import SwiftBundlerRuntime

#if canImport(SwiftBundlerRuntime)
import SwiftBundlerRuntime
#endif

struct Person {
var name: String
Expand Down
5 changes: 4 additions & 1 deletion Examples/Sources/StressTestExample/StressTestApp.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import SelectedBackend
import SwiftCrossUI
import SwiftBundlerRuntime

#if canImport(SwiftBundlerRuntime)
import SwiftBundlerRuntime
#endif

class StressTestState: Observable {
@Observed
Expand Down
5 changes: 4 additions & 1 deletion Examples/Sources/WindowingExample/WindowingApp.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Foundation
import SelectedBackend
import SwiftCrossUI
import SwiftBundlerRuntime

#if canImport(SwiftBundlerRuntime)
import SwiftBundlerRuntime
#endif

class WindowingAppState: Observable {
@Observed var title = "My window"
Expand Down
11 changes: 8 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ if let backend = ProcessInfo.processInfo.environment["SCUI_DEFAULT_BACKEND"] {
#endif
}

let hotReloadingEnabled =
ProcessInfo.processInfo.environment["SWIFT_BUNDLER_HOT_RELOADING"] != nil
|| ProcessInfo.processInfo.environment["SCUI_HOT_RELOADING"] != nil
let hotReloadingEnabled: Bool
#if os(Windows)
hotReloadingEnabled = false
#else
hotReloadingEnabled =
ProcessInfo.processInfo.environment["SWIFT_BUNDLER_HOT_RELOADING"] != nil
|| ProcessInfo.processInfo.environment["SCUI_HOT_RELOADING"] != nil
#endif

var swiftSettings: [SwiftSetting] = []
if hotReloadingEnabled {
Expand Down

0 comments on commit c72824c

Please sign in to comment.