Skip to content

Bump to Swift 6.1 Toolchain #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 11, 2025
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
33 changes: 33 additions & 0 deletions .github/scripts/fix-toolchain.sh
Original file line number Diff line number Diff line change
@@ -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 <ptrauth.h>/\/\/ #include <ptrauth.h>/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
7 changes: 5 additions & 2 deletions .github/workflows/compatibility_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand Down
6 changes: 3 additions & 3 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlatformViewDefinition.ViewKind>) -> AnyObject {
_makeView(kind: kind.pointee)
}

override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> 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<PlatformViewDefinition.ViewKind>) -> 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
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlatformViewDefinition.ViewKind>) -> AnyObject {
_makeView(kind: kind.pointee)
}

override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject {
preconditionFailure("TODO")
}
#else
override static func makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject {
_makeView(kind: kind)
}

override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> 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:
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Sources/OpenSwiftUI/Scene/Core/Scene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
// Audited for iOS 15.5
// Status: Empty

#if canImport(CoreTransferable)
import CoreTransferable
#endif

public protocol Scene {
associatedtype Body: Scene

@SceneBuilder
var body: Self.Body { get }
// static func _makeScene(scene: _GraphValue<Self>, inputs: _SceneInputs) -> _SceneOutputs
}

extension Never: Scene {}

extension Scene {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ extension DisplayList {
@_silgen_name("OpenSwiftUITestStub_DisplayListViewRendererRenderRootView")
package func swiftUI_render(
rootView: AnyObject,
from list: UnsafePointer<DisplayList>,
time: UnsafePointer<Time>,
nextTime: UnsafePointer<Time>,
version: UnsafePointer<DisplayList.Version>,
maxVersion: UnsafePointer<DisplayList.Version>,
environment: UnsafePointer<DisplayList.ViewRenderer.Environment>
from list: DisplayList,
time: Time,
nextTime: Time,
version: DisplayList.Version,
maxVersion: DisplayList.Version,
environment: DisplayList.ViewRenderer.Environment
) -> Time
#endif

Expand Down
9 changes: 0 additions & 9 deletions Sources/OpenSwiftUICore/Render/PlatformViewDefinition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,11 @@ open class PlatformViewDefinition: @unchecked Sendable {
}

open class var system: PlatformViewDefinition.System { .init(base: .swiftUIView) }

#if _OPENSWIFTUI_SWIFTUI_RENDER
open class func makeView(kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject { preconditionFailure("") }
#if canImport(Darwin)
open class func makeLayerView(type: CALayer.Type, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject { preconditionFailure("") }
#endif
open class func makePlatformView(view: AnyObject, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) { preconditionFailure("") }
#else
open class func makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject { preconditionFailure("") }
#if canImport(Darwin)
open class func makeLayerView(type: CALayer.Type, kind: PlatformViewDefinition.ViewKind) -> AnyObject { preconditionFailure("") }
#endif
open class func makePlatformView(view: AnyObject, kind: PlatformViewDefinition.ViewKind) { preconditionFailure("") }
#endif
open class func makeDrawingView(options: PlatformDrawableOptions) -> any PlatformDrawable { preconditionFailure("") }
open class func setPath(_ path: Path, shapeView: AnyObject) { preconditionFailure("") }
open class func setProjectionTransform(_ transform: ProjectionTransform, projectionView: AnyObject) { preconditionFailure("") }
Expand Down
9 changes: 5 additions & 4 deletions Sources/OpenSwiftUICore/View/IDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ extension View {
extension IDView {
@usableFromInline
package static func _makeView(view: _GraphValue<Self>, inputs: _ViewInputs) -> _ViewOutputs {
if _SemanticFeature_v2.isEnabled {
return makeImplicitRoot(view: view, inputs: inputs)
} else {
// FIXME: makeImplicitRoot is not implemented yet
// if _SemanticFeature_v2.isEnabled {
// return makeImplicitRoot(view: view, inputs: inputs)
// } else {
let id = view.value[offset: { .of(&$0.id) }]
let phase = IDPhase(id: id, phase: inputs.viewPhase, lastID: nil, delta: 0)
var inputs = inputs
inputs.viewPhase = Attribute(phase)
return Content.makeDebuggableView(view: view[offset: { .of(&$0.content)}], inputs: inputs)
}
// }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ struct AppearanceActionModifierTests {
#endif
}

#if !DEBUG || compiler(>=6.1)
// For Xcode 16.3-/Swift 6.1-, Xcode will infer OpaqueTypeErasure to be true which will make some difference to the result.
// And there is no way to opt-out it for package yet.
@Test
func idTest() async throws {
enum Helper {
Expand Down Expand Up @@ -69,6 +66,5 @@ struct AppearanceActionModifierTests {
#expect(Helper.result.hasPrefix("AAD"))
#endif
}
#endif
}
#endif
Loading