Skip to content

Commit

Permalink
Fix build on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
rensbreur committed Jul 9, 2024
1 parent 9095357 commit 5371330
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/SwiftTUI/RunLoop/Application.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Foundation
#if os(macOS)
import AppKit
#endif

public class Application {
private let node: Node
Expand Down Expand Up @@ -41,10 +43,12 @@ public class Application {
/// The default option, using Dispatch for the main run loop.
case dispatch

#if os(macOS)
/// This creates and runs an NSApplication with an associated run loop. This allows you
/// e.g. to open NSWindows running simultaneously to the terminal app. This requires macOS
/// and AppKit.
case cocoa
#endif
}

public func start() {
Expand All @@ -70,9 +74,11 @@ public class Application {
switch runLoopType {
case .dispatch:
dispatchMain()
#if os(macOS)
case .cocoa:
NSApplication.shared.setActivationPolicy(.accessory)
NSApplication.shared.run()
#endif
}
}

Expand Down

0 comments on commit 5371330

Please sign in to comment.