Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Example/Example/BenchmarkApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import OpenSwiftUI
import SwiftUI
#endif

#if os(iOS) || os(visionOS)
import UIKit
#endif

struct BenchmarkApp {
static func main() {
_TestApp().runBenchmarks([
Expand Down
2 changes: 0 additions & 2 deletions Example/Example/ExampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct ExampleApp: App {
}

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import AppKit
private class AppDelegate: NSResponder, NSApplicationDelegate {
var window: NSWindow?

Expand All @@ -35,7 +34,6 @@ private class AppDelegate: NSResponder, NSApplicationDelegate {
}
}
#else
import UIKit
private class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

Expand Down
35 changes: 15 additions & 20 deletions Example/Example/ObservableExampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ private struct ContentViewWrapper: View {
}

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
// Avoid AppKit export Foundation and Foundation export Observation issue.
// Then Observation's Observable macro will conflict with OpenObservation's Observable macro.
import class AppKit.NSResponder
import class AppKit.NSWindow
import protocol AppKit.NSApplicationDelegate
import struct Foundation.Notification
@Observable
#if OPENSWIFTUI
@OpenObservation::Observable
#else
@Observation::Observable
#endif
private class AppDelegate: NSResponder, NSApplicationDelegate {
var window: NSWindow?

Expand All @@ -60,18 +58,11 @@ private class AppDelegate: NSResponder, NSApplicationDelegate {
}
}
#else
// Avoid UIKit export Foundation and Foundation export Observation issue.
// Then Observation's Observable macro will conflict with OpenObservation's Observable macro.
import class UIKit.UIApplication
import class UIKit.UIResponder
import class UIKit.UIScene
import class UIKit.UISceneConfiguration
import class UIKit.UISceneSession
import class UIKit.UIWindow
import protocol UIKit.UIApplicationDelegate
import protocol UIKit.UIWindowSceneDelegate

@Observable
#if OPENSWIFTUI
@OpenObservation::Observable
#else
@Observation::Observable
#endif
private class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

Expand All @@ -97,7 +88,11 @@ private class AppDelegate: UIResponder, UIApplicationDelegate {
}
}

@Observable
#if OPENSWIFTUI
@OpenObservation::Observable
#else
@Observation::Observable
#endif
private class SceneDelegate: NSObject, UIWindowSceneDelegate {
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
print("SceneDelegate will connect to scene: \(scene), session: \(session), options: \(connectionOptions)")
Expand Down
2 changes: 0 additions & 2 deletions Example/Example/ObservableObjectExampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ private struct ContentViewWrapper: View {
}

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import AppKit
private class AppDelegate: NSResponder, NSApplicationDelegate, ObservableObject {
var window: NSWindow?

Expand All @@ -58,7 +57,6 @@ private class AppDelegate: NSResponder, NSApplicationDelegate, ObservableObject
}
}
#else
import UIKit
private class AppDelegate: UIResponder, UIApplicationDelegate, ObservableObject {
var window: UIWindow?

Expand Down
6 changes: 0 additions & 6 deletions Example/HostingExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import OpenSwiftUI
import SwiftUI
#endif

#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
#endif

#if os(iOS) || os(visionOS)
class ViewController: UINavigationController {
override func viewDidAppear(_ animated: Bool) {
Expand Down
12 changes: 10 additions & 2 deletions Example/Shared/Data/ObservationExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ struct ObservationExample: View {
}
}

@Observable
#if OPENSWIFTUI
@OpenObservation::Observable
#else
@Observation::Observable
#endif
private class ColorModel {
var showRed = false
}
Expand All @@ -42,7 +46,11 @@ struct ObservationColorExample: View {
ObservationColorExample()
}

@Observable
#if OPENSWIFTUI
@OpenObservation::Observable
#else
@Observation::Observable
#endif
private final class CounterModel {
var count = 0
}
Expand Down
2 changes: 0 additions & 2 deletions Example/Shared/Extension/Platform+TypeAlias.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ public import SwiftUI
#endif

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
public import AppKit
public typealias PlatformColor = NSColor
public typealias PlatformImage = NSImage
public typealias PlatformView = NSView
public typealias PlatformViewController = NSViewController
public typealias PlatformHostingController = NSHostingController
public typealias PlatformHostingView = NSHostingView
#elseif canImport(UIKit)
public import UIKit
public typealias PlatformColor = UIColor
public typealias PlatformImage = UIImage
public typealias PlatformView = UIView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@

import QuartzCore

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import AppKit
#elseif canImport(UIKit)
import UIKit
#endif

#if !OPENSWIFTUI
@available(iOS 18.0, macOS 15.0, *)
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import SwiftUI
#endif

#if os(iOS) || os(visionOS)
import UIKit
typealias PlatformViewRepresentable = UIViewRepresentable
typealias PlatformViewControllerRepresentable = UIViewControllerRepresentable
#elseif os(macOS)
import AppKit
typealias PlatformViewRepresentable = NSViewRepresentable
typealias PlatformViewControllerRepresentable = NSViewControllerRepresentable
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ struct ForEachNonConstantRangeView: View {
}
}

@Observable
#if OPENSWIFTUI
@OpenObservation::Observable
#else
@Observation::Observable
#endif
private class ForEachLazyContainerNonConstantCountViewModel {
var data: [Int] = [1, 2]
}
Expand Down
6 changes: 0 additions & 6 deletions Example/Shared/View/Image/ImageConversionsExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import OpenSwiftUI
import SwiftUI
#endif

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import AppKit
#elseif canImport(UIKit)
import UIKit
#endif

struct ImageConversionsExample: View {
var body: some View {
HStack(spacing: 0) {
Expand Down
3 changes: 0 additions & 3 deletions Example/Shared/View/Text/FontPlayground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import OpenSwiftUI
#else
import SwiftUI
#endif
#if canImport(UIKit)
import UIKit
#endif

// Examples adapted from “SwiftUI under the Hood: Fonts”:
// https://movingparts.io/fonts-in-swiftui
Expand Down
6 changes: 0 additions & 6 deletions Example/TestingHost/TestingHostApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import OpenSwiftUI
import SwiftUI
#endif

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import AppKit
#else
import UIKit
#endif

@main
struct TestingHostApp: App {
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ struct ObservationInteractionTests {
}
}

@Observable
#if OPENSWIFTUI
@OpenObservation::Observable
#else
@Observation::Observable
#endif
private final class CounterModel {
var count = 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
// InteractionTestHost.swift
// OpenSwiftUIInteractionTests

#if os(macOS)
import AppKit
#elseif os(iOS)
import UIKit
#endif
import Foundation
import Hammer
#if OPENSWIFTUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import Testing
import TestingHost
import SnapshotTesting

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import AppKit
#elseif canImport(UIKit)
import UIKit
#endif

@MainActor
@Suite(.snapshots(record: .never, diffTool: diffTool))
struct HostingViewUITests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import Testing
import SnapshotTesting

#if os(iOS) || os(visionOS)
import UIKit
typealias PlatformViewControllerRepresentable = UIViewControllerRepresentable
#elseif os(macOS)
import AppKit
typealias PlatformViewControllerRepresentable = NSViewControllerRepresentable
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import Testing
import SnapshotTesting

#if os(iOS) || os(visionOS)
import UIKit
typealias PlatformViewRepresentable = UIViewRepresentable
#elseif os(macOS)
import AppKit
typealias PlatformViewRepresentable = NSViewRepresentable
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// OpenSwiftUIUITests

#if os(macOS)
import AppKit
import SnapshotTesting
import Testing
@testable import TestingHost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// SnapshotTesting+Testing.swift
// OpenSwiftUIUITests

#if os(macOS)
import AppKit
#endif
import Foundation
import SnapshotTesting
import TestingHost
Expand Down
5 changes: 0 additions & 5 deletions Sources/OpenSwiftUI/Accessibility/AccessibilityAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

import Foundation
import OpenSwiftUICore
#if os(iOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import AppKit
#endif

// MARK: - AccessibilityAction

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

public import OpenSwiftUICore
import OpenSwiftUI_SPI
#if os(macOS)
import AppKit
#endif

// MARK: - AccessibilityAdjustmentDirection

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#if canImport(UIKit)
import Accessibility
package import OpenSwiftUICore
import UIKit

extension AccessibilityCore {
package enum UserSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import OpenAttributeGraphShims
@_spi(ForOpenSwiftUIOnly)
import OpenSwiftUICore
#if os(macOS)
import AppKit
import COpenSwiftUI
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import OpenSwiftUICore
import struct OpenSwiftUICore.UniqueID

#if canImport(UIKit)
import UIKit
typealias AccessibilityNodeBase = UIResponder
#else
typealias AccessibilityNodeBase = NSObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
// Status: WIP (TBA)

import Foundation
#if canImport(UIKit)
import UIKit
#endif

// MARK: - AccessibilityRotorEntryRange [TBA]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// ID: F9F3632E7F7BE116C99E79BEEDA2329B (SwiftUI)

#if os(macOS)
public import AppKit
import COpenSwiftUI
@_spi(ForOpenSwiftUIOnly)
import OpenSwiftUICore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import COpenSwiftUI
import OpenSwiftUICore
import OpenSwiftUI_SPI
import libAccessibilityPrivate
import UIKit

// MARK: - UILargeContentViewerInteractionBridge [WIP]

Expand Down
2 changes: 0 additions & 2 deletions Sources/OpenSwiftUI/App/App/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,10 @@ func applyAppRootModifier(_ view: AnyView) -> AnyView {
// MARK: - Platform implementation

#if os(iOS) || os(visionOS)
import UIKit
typealias DelegateBaseClass = UIResponder
typealias PlatformApplication = UIApplication
typealias PlatformApplicationDelegate = UIApplicationDelegate
#elseif os(macOS)
import AppKit
typealias DelegateBaseClass = NSResponder
typealias PlatformApplication = NSApplication
typealias PlatformApplicationDelegate = NSApplicationDelegate
Expand Down
1 change: 0 additions & 1 deletion Sources/OpenSwiftUI/App/App/AppKit/AppKitApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
@_spi(ForOpenSwiftUIOnly)
@_spi(Private)
import OpenSwiftUICore
import AppKit

// MARK: - runApp

Expand Down
Loading
Loading