diff --git a/.github/scripts/fix-toolchain.sh b/.github/scripts/fix-toolchain.sh new file mode 100755 index 00000000..447ef4c7 --- /dev/null +++ b/.github/scripts/fix-toolchain.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -e + +# Find the path to swift binary +SWIFT_PATH=$(which swift) +echo "Swift binary found at: $SWIFT_PATH" + +# Extract the toolchain path from swift binary path +# Remove /usr/bin/swift from the path to get the toolchain root +TOOLCHAIN_ROOT=$(dirname $(dirname "$SWIFT_PATH")) +echo "Toolchain root: $TOOLCHAIN_ROOT" + +# Construct the path to CFBase.h +CFBASE_PATH="$TOOLCHAIN_ROOT/lib/swift/CoreFoundation/CFBase.h" +echo "Looking for CFBase.h at: $CFBASE_PATH" + +# Check if the file exists +if [ -f "$CFBASE_PATH" ]; then + echo "Found CFBase.h, applying patch..." + + # Create a backup of the original file + cp "$CFBASE_PATH" "$CFBASE_PATH.bak" + + # Replace the include line + sed -i 's/#include /\/\/ #include /g' "$CFBASE_PATH" + + echo "Patch applied successfully." + echo "Original file backed up at $CFBASE_PATH.bak" +else + echo "ERROR: Could not find CFBase.h in expected location." + echo "Toolchain structure may be different than expected." + exit 1 +fi diff --git a/.github/workflows/compatibility_tests.yml b/.github/workflows/compatibility_tests.yml index 971e9217..90b9c36d 100644 --- a/.github/workflows/compatibility_tests.yml +++ b/.github/workflows/compatibility_tests.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [macos-15] - xcode-version: ["16.0"] + xcode-version: ["16.3"] release: [2024] runs-on: ${{ matrix.os }} env: @@ -23,10 +23,13 @@ jobs: OPENSWIFTUI_SWIFT_CRYPTO: 0 OPENSWIFTUI_TARGET_RELEASE: ${{ matrix.release }} OPENSWIFTUI_USE_LOCAL_DEPS: 1 + OPENSWIFTUI_LIBRARY_EVOLUTION: 0 OPENGRAPH_USE_LOCAL_DEPS: 1 OPENGRAPH_TARGET_RELEASE: ${{ matrix.release }} + OPENGRAPH_LIBRARY_EVOLUTION: 0 OPENBOX_USE_LOCAL_DEPS: 1 OPENBOX_TARGET_RELEASE: ${{ matrix.release }} + OPENBOX_LIBRARY_EVOLUTION: 0 DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: ${{ matrix.release }} GH_TOKEN: ${{ github.token }} steps: @@ -60,7 +63,7 @@ jobs: fail-fast: false matrix: os: [macos-15] - xcode-version: ["16.0"] + xcode-version: ["16.3"] release: [2024] ios-version: ["18.0"] include: diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 110d45dd..3c9dfb69 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [macos-15] - xcode-version: ["16.0"] + xcode-version: ["16.3"] release: [2024] ios-version: ["18.0"] include: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 5b081683..a58ef65e 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [macos-15] - xcode-version: ["16.0"] + xcode-version: ["16.3"] release: [2024] runs-on: ${{ matrix.os }} env: @@ -24,10 +24,13 @@ jobs: OPENSWIFTUI_SWIFT_CRYPTO: 0 OPENSWIFTUI_TARGET_RELEASE: ${{ matrix.release }} OPENSWIFTUI_USE_LOCAL_DEPS: 1 + OPENSWIFTUI_LIBRARY_EVOLUTION: 0 OPENGRAPH_USE_LOCAL_DEPS: 1 OPENGRAPH_TARGET_RELEASE: ${{ matrix.release }} + OPENGRAPH_LIBRARY_EVOLUTION: 0 OPENBOX_USE_LOCAL_DEPS: 1 OPENBOX_TARGET_RELEASE: ${{ matrix.release }} + OPENBOX_LIBRARY_EVOLUTION: 0 DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: ${{ matrix.release }} GH_TOKEN: ${{ github.token }} steps: diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 5777f73b..df8811c0 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - swift_version: ["6.0.1"] + swift_version: ["6.1.0"] runs-on: ubuntu-22.04 env: OPENSWIFTUI_WERROR: 1 @@ -23,6 +23,10 @@ jobs: container: swift:${{ matrix.swift_version }}-jammy steps: - uses: actions/checkout@v4 + - name: Toolchain fix patch + run: | + # Fix swift-corelibs-foundation#5211 + .github/scripts/fix-toolchain.sh - name: Building and running tests in debug mode with coverage run: | swift test \ diff --git a/Package.resolved b/Package.resolved index 42cac7e4..e5aca921 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "c72e2bc714f92bcf02092961f7be834040b491a370d9391bb55c683896efa9b3", + "originHash" : "b8dba5018ecd3b79f322feb006138a2525dcd0f4c48de35ff3b0b8786ebe71e3", "pins" : [ { "identity" : "darwinprivateframeworks", @@ -16,7 +16,7 @@ "location" : "https://github.com/OpenSwiftUIProject/OpenBox", "state" : { "branch" : "main", - "revision" : "de81c145fd3ef582d4cb41b2190febf487ce6125" + "revision" : "fb184f50625b66bfab4c6cb629621734a36e5e95" } }, { @@ -25,7 +25,7 @@ "location" : "https://github.com/OpenSwiftUIProject/OpenGraph", "state" : { "branch" : "main", - "revision" : "5204ae0d031a520df99b5b2f32c5c9ddbfdb5036" + "revision" : "b71c1d472b2dd054ebc4eae32243e47f78404168" } }, { diff --git a/Package.swift b/Package.swift index 91b165bf..794f2916 100644 --- a/Package.swift +++ b/Package.swift @@ -123,6 +123,19 @@ if warningsAsErrorsCondition { // sharedSwiftSettings.append(.unsafeFlags(["-Wwarning", "concurrency"])) } +// MARK: - [env] OPENSWIFTUI_LIBRARY_EVOLUTION + +#if os(macOS) +let libraryEvolutionCondition = envEnable("OPENSWIFTUI_LIBRARY_EVOLUTION", default: true) +#else +let libraryEvolutionCondition = envEnable("OPENSWIFTUI_LIBRARY_EVOLUTION") +#endif + +if libraryEvolutionCondition { + // NOTE: -enable-library-evolution is not supported on `swift build` yet. + sharedSwiftSettings.append(.unsafeFlags(["-enable-library-evolution"])) +} + // MARK: - CoreGraphicsShims Target let coreGraphicsShimsTarget = Target.target( @@ -352,7 +365,7 @@ let package = Package( name: "OpenSwiftUI", products: products, dependencies: [ - .package(url: "https://github.com/apple/swift-numerics.git", from: "1.0.3"), + .package(url: "https://github.com/apple/swift-numerics", from: "1.0.3"), ], targets: [ // TODO: Add SwiftGTK as an backend alternative for UIKit/AppKit on Linux and macOS diff --git a/README.md b/README.md index d33ff290..fe02e2cf 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ See Example folder and try it with ExampleApp ## Build -The current suggested toolchain to build the project is Swift 6.0 / Xcode 16.0. +The current suggested toolchain to build the project is Swift 6.1 / Xcode 16.3. ### Build without testing framework diff --git a/Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift b/Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift index 5e69ee40..0df68c25 100644 --- a/Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift +++ b/Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift @@ -534,28 +534,15 @@ extension _UIHostingView: ViewRendererHost { let scale = window?.screen.scale ?? 1 let environment = DisplayList.ViewRenderer.Environment(contentsScale: scale) #if canImport(SwiftUI, _underlyingVersion: 6.0.87) && _OPENSWIFTUI_SWIFTUI_RENDER - return withUnsafePointer(to: list) { list in - withUnsafePointer(to: time) { time in - withUnsafePointer(to: nextTime) { nextTime in - withUnsafePointer(to: version) { version in - withUnsafePointer(to: maxVersion) { maxVersion in - withUnsafePointer(to: environment) { environment in - return renderer - .swiftUI_render( - rootView: self, - from: list, - time: time, - nextTime: nextTime, - version: version, - maxVersion: maxVersion, - environment: environment - ) - } - } - } - } - } - } + return renderer.swiftUI_render( + rootView: self, + from: list, + time: time, + nextTime: nextTime, + version: version, + maxVersion: maxVersion, + environment: environment + ) #else return renderer.render( rootView: self, diff --git a/Sources/OpenSwiftUI/Integration/Render/AppKit/NSViewPlatformViewDefinition.swift b/Sources/OpenSwiftUI/Integration/Render/AppKit/NSViewPlatformViewDefinition.swift index 1cca82f9..7afc54ea 100644 --- a/Sources/OpenSwiftUI/Integration/Render/AppKit/NSViewPlatformViewDefinition.swift +++ b/Sources/OpenSwiftUI/Integration/Render/AppKit/NSViewPlatformViewDefinition.swift @@ -13,28 +13,13 @@ import AppKit final class NSViewPlatformViewDefinition: PlatformViewDefinition, @unchecked Sendable { override final class var system: PlatformViewDefinition.System { .nsView } - #if _OPENSWIFTUI_SWIFTUI_RENDER - override static func makeView(kind: UnsafePointer) -> AnyObject { - _makeView(kind: kind.pointee) - } - - override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer) -> AnyObject { - preconditionFailure("TODO") - } - #else override static func makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject { - _makeView(kind: kind) + // TODO + return NSView() } - override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer) -> AnyObject { + override static func makeLayerView(type: CALayer.Type, kind: PlatformViewDefinition.ViewKind) -> AnyObject { preconditionFailure("TODO") } - #endif - - // FIXME: A shim for _OPENSWIFTUI_SWIFTUI_RENDER - private static func _makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject { - // TODO - return NSView() - } } #endif diff --git a/Sources/OpenSwiftUI/Integration/Render/UIKit/UIViewPlatformViewDefinition.swift b/Sources/OpenSwiftUI/Integration/Render/UIKit/UIViewPlatformViewDefinition.swift index 4dd84a15..8fca851b 100644 --- a/Sources/OpenSwiftUI/Integration/Render/UIKit/UIViewPlatformViewDefinition.swift +++ b/Sources/OpenSwiftUI/Integration/Render/UIKit/UIViewPlatformViewDefinition.swift @@ -15,26 +15,7 @@ import OpenSwiftUISymbolDualTestsSupport final class UIViewPlatformViewDefinition: PlatformViewDefinition, @unchecked Sendable { override final class var system: PlatformViewDefinition.System { .uiView } - #if _OPENSWIFTUI_SWIFTUI_RENDER - override static func makeView(kind: UnsafePointer) -> AnyObject { - _makeView(kind: kind.pointee) - } - - override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer) -> AnyObject { - preconditionFailure("TODO") - } - #else override static func makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject { - _makeView(kind: kind) - } - - override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer) -> AnyObject { - preconditionFailure("TODO") - } - #endif - - // FIXME: A shim for _OPENSWIFTUI_SWIFTUI_RENDER - private static func _makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject { let view: UIView switch kind { case .mask: @@ -48,6 +29,10 @@ final class UIViewPlatformViewDefinition: PlatformViewDefinition, @unchecked Sen return view } + override static func makeLayerView(type: CALayer.Type, kind: PlatformViewDefinition.ViewKind) -> AnyObject { + preconditionFailure("TODO") + } + private static func initView(_ view: UIView, kind: PlatformViewDefinition.ViewKind) { if kind != .platformView && kind != .platformGroup { view.autoresizesSubviews = false diff --git a/Sources/OpenSwiftUI/Scene/Core/Scene.swift b/Sources/OpenSwiftUI/Scene/Core/Scene.swift index c15499bc..9929ad2a 100644 --- a/Sources/OpenSwiftUI/Scene/Core/Scene.swift +++ b/Sources/OpenSwiftUI/Scene/Core/Scene.swift @@ -5,6 +5,10 @@ // Audited for iOS 15.5 // Status: Empty +#if canImport(CoreTransferable) +import CoreTransferable +#endif + public protocol Scene { associatedtype Body: Scene @@ -12,6 +16,7 @@ public protocol Scene { var body: Self.Body { get } // static func _makeScene(scene: _GraphValue, inputs: _SceneInputs) -> _SceneOutputs } + extension Never: Scene {} extension Scene { diff --git a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayListViewRenderer.swift b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayListViewRenderer.swift index f919ca3f..c51395db 100644 --- a/Sources/OpenSwiftUICore/Render/DisplayList/DisplayListViewRenderer.swift +++ b/Sources/OpenSwiftUICore/Render/DisplayList/DisplayListViewRenderer.swift @@ -102,12 +102,12 @@ extension DisplayList { @_silgen_name("OpenSwiftUITestStub_DisplayListViewRendererRenderRootView") package func swiftUI_render( rootView: AnyObject, - from list: UnsafePointer, - time: UnsafePointer