Skip to content

Commit b64842c

Browse files
authored
Bump to Swift 6.1 Toolchain (#276)
* Bump to Swift 6.1 Toolchain * Add fix-toolchain.sh to workaround Linux toolchain issue * Fix IDView crash * Add OPENSWIFTUI_LIBRARY_EVOLUTION to fix the ABI call issue * Update OG and OB version * Fix library_evolution issue for swift build
1 parent 6f03a71 commit b64842c

File tree

17 files changed

+98
-128
lines changed

17 files changed

+98
-128
lines changed

.github/scripts/fix-toolchain.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Find the path to swift binary
5+
SWIFT_PATH=$(which swift)
6+
echo "Swift binary found at: $SWIFT_PATH"
7+
8+
# Extract the toolchain path from swift binary path
9+
# Remove /usr/bin/swift from the path to get the toolchain root
10+
TOOLCHAIN_ROOT=$(dirname $(dirname "$SWIFT_PATH"))
11+
echo "Toolchain root: $TOOLCHAIN_ROOT"
12+
13+
# Construct the path to CFBase.h
14+
CFBASE_PATH="$TOOLCHAIN_ROOT/lib/swift/CoreFoundation/CFBase.h"
15+
echo "Looking for CFBase.h at: $CFBASE_PATH"
16+
17+
# Check if the file exists
18+
if [ -f "$CFBASE_PATH" ]; then
19+
echo "Found CFBase.h, applying patch..."
20+
21+
# Create a backup of the original file
22+
cp "$CFBASE_PATH" "$CFBASE_PATH.bak"
23+
24+
# Replace the include line
25+
sed -i 's/#include <ptrauth.h>/\/\/ #include <ptrauth.h>/g' "$CFBASE_PATH"
26+
27+
echo "Patch applied successfully."
28+
echo "Original file backed up at $CFBASE_PATH.bak"
29+
else
30+
echo "ERROR: Could not find CFBase.h in expected location."
31+
echo "Toolchain structure may be different than expected."
32+
exit 1
33+
fi

.github/workflows/compatibility_tests.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: [macos-15]
16-
xcode-version: ["16.0"]
16+
xcode-version: ["16.3"]
1717
release: [2024]
1818
runs-on: ${{ matrix.os }}
1919
env:
@@ -23,10 +23,13 @@ jobs:
2323
OPENSWIFTUI_SWIFT_CRYPTO: 0
2424
OPENSWIFTUI_TARGET_RELEASE: ${{ matrix.release }}
2525
OPENSWIFTUI_USE_LOCAL_DEPS: 1
26+
OPENSWIFTUI_LIBRARY_EVOLUTION: 0
2627
OPENGRAPH_USE_LOCAL_DEPS: 1
2728
OPENGRAPH_TARGET_RELEASE: ${{ matrix.release }}
29+
OPENGRAPH_LIBRARY_EVOLUTION: 0
2830
OPENBOX_USE_LOCAL_DEPS: 1
2931
OPENBOX_TARGET_RELEASE: ${{ matrix.release }}
32+
OPENBOX_LIBRARY_EVOLUTION: 0
3033
DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: ${{ matrix.release }}
3134
GH_TOKEN: ${{ github.token }}
3235
steps:
@@ -60,7 +63,7 @@ jobs:
6063
fail-fast: false
6164
matrix:
6265
os: [macos-15]
63-
xcode-version: ["16.0"]
66+
xcode-version: ["16.3"]
6467
release: [2024]
6568
ios-version: ["18.0"]
6669
include:

.github/workflows/ios.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: [macos-15]
16-
xcode-version: ["16.0"]
16+
xcode-version: ["16.3"]
1717
release: [2024]
1818
ios-version: ["18.0"]
1919
include:

.github/workflows/macos.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: [macos-15]
16-
xcode-version: ["16.0"]
16+
xcode-version: ["16.3"]
1717
release: [2024]
1818
runs-on: ${{ matrix.os }}
1919
env:
@@ -24,10 +24,13 @@ jobs:
2424
OPENSWIFTUI_SWIFT_CRYPTO: 0
2525
OPENSWIFTUI_TARGET_RELEASE: ${{ matrix.release }}
2626
OPENSWIFTUI_USE_LOCAL_DEPS: 1
27+
OPENSWIFTUI_LIBRARY_EVOLUTION: 0
2728
OPENGRAPH_USE_LOCAL_DEPS: 1
2829
OPENGRAPH_TARGET_RELEASE: ${{ matrix.release }}
30+
OPENGRAPH_LIBRARY_EVOLUTION: 0
2931
OPENBOX_USE_LOCAL_DEPS: 1
3032
OPENBOX_TARGET_RELEASE: ${{ matrix.release }}
33+
OPENBOX_LIBRARY_EVOLUTION: 0
3134
DARWIN_PRIVATE_FRAMEWORKS_TARGET_RELEASE: ${{ matrix.release }}
3235
GH_TOKEN: ${{ github.token }}
3336
steps:

.github/workflows/ubuntu.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
swift_version: ["6.0.1"]
15+
swift_version: ["6.1.0"]
1616
runs-on: ubuntu-22.04
1717
env:
1818
OPENSWIFTUI_WERROR: 1
@@ -23,6 +23,10 @@ jobs:
2323
container: swift:${{ matrix.swift_version }}-jammy
2424
steps:
2525
- uses: actions/checkout@v4
26+
- name: Toolchain fix patch
27+
run: |
28+
# Fix swift-corelibs-foundation#5211
29+
.github/scripts/fix-toolchain.sh
2630
- name: Building and running tests in debug mode with coverage
2731
run: |
2832
swift test \

Package.resolved

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"originHash" : "c72e2bc714f92bcf02092961f7be834040b491a370d9391bb55c683896efa9b3",
2+
"originHash" : "b8dba5018ecd3b79f322feb006138a2525dcd0f4c48de35ff3b0b8786ebe71e3",
33
"pins" : [
44
{
55
"identity" : "darwinprivateframeworks",
@@ -16,7 +16,7 @@
1616
"location" : "https://github.com/OpenSwiftUIProject/OpenBox",
1717
"state" : {
1818
"branch" : "main",
19-
"revision" : "de81c145fd3ef582d4cb41b2190febf487ce6125"
19+
"revision" : "fb184f50625b66bfab4c6cb629621734a36e5e95"
2020
}
2121
},
2222
{
@@ -25,7 +25,7 @@
2525
"location" : "https://github.com/OpenSwiftUIProject/OpenGraph",
2626
"state" : {
2727
"branch" : "main",
28-
"revision" : "5204ae0d031a520df99b5b2f32c5c9ddbfdb5036"
28+
"revision" : "b71c1d472b2dd054ebc4eae32243e47f78404168"
2929
}
3030
},
3131
{

Package.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ if warningsAsErrorsCondition {
123123
// sharedSwiftSettings.append(.unsafeFlags(["-Wwarning", "concurrency"]))
124124
}
125125

126+
// MARK: - [env] OPENSWIFTUI_LIBRARY_EVOLUTION
127+
128+
#if os(macOS)
129+
let libraryEvolutionCondition = envEnable("OPENSWIFTUI_LIBRARY_EVOLUTION", default: true)
130+
#else
131+
let libraryEvolutionCondition = envEnable("OPENSWIFTUI_LIBRARY_EVOLUTION")
132+
#endif
133+
134+
if libraryEvolutionCondition {
135+
// NOTE: -enable-library-evolution is not supported on `swift build` yet.
136+
sharedSwiftSettings.append(.unsafeFlags(["-enable-library-evolution"]))
137+
}
138+
126139
// MARK: - CoreGraphicsShims Target
127140

128141
let coreGraphicsShimsTarget = Target.target(
@@ -352,7 +365,7 @@ let package = Package(
352365
name: "OpenSwiftUI",
353366
products: products,
354367
dependencies: [
355-
.package(url: "https://github.com/apple/swift-numerics.git", from: "1.0.3"),
368+
.package(url: "https://github.com/apple/swift-numerics", from: "1.0.3"),
356369
],
357370
targets: [
358371
// TODO: Add SwiftGTK as an backend alternative for UIKit/AppKit on Linux and macOS

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ See Example folder and try it with ExampleApp
3232
3333
## Build
3434

35-
The current suggested toolchain to build the project is Swift 6.0 / Xcode 16.0.
35+
The current suggested toolchain to build the project is Swift 6.1 / Xcode 16.3.
3636

3737
### Build without testing framework
3838

Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -534,28 +534,15 @@ extension _UIHostingView: ViewRendererHost {
534534
let scale = window?.screen.scale ?? 1
535535
let environment = DisplayList.ViewRenderer.Environment(contentsScale: scale)
536536
#if canImport(SwiftUI, _underlyingVersion: 6.0.87) && _OPENSWIFTUI_SWIFTUI_RENDER
537-
return withUnsafePointer(to: list) { list in
538-
withUnsafePointer(to: time) { time in
539-
withUnsafePointer(to: nextTime) { nextTime in
540-
withUnsafePointer(to: version) { version in
541-
withUnsafePointer(to: maxVersion) { maxVersion in
542-
withUnsafePointer(to: environment) { environment in
543-
return renderer
544-
.swiftUI_render(
545-
rootView: self,
546-
from: list,
547-
time: time,
548-
nextTime: nextTime,
549-
version: version,
550-
maxVersion: maxVersion,
551-
environment: environment
552-
)
553-
}
554-
}
555-
}
556-
}
557-
}
558-
}
537+
return renderer.swiftUI_render(
538+
rootView: self,
539+
from: list,
540+
time: time,
541+
nextTime: nextTime,
542+
version: version,
543+
maxVersion: maxVersion,
544+
environment: environment
545+
)
559546
#else
560547
return renderer.render(
561548
rootView: self,

Sources/OpenSwiftUI/Integration/Render/AppKit/NSViewPlatformViewDefinition.swift

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,13 @@ import AppKit
1313
final class NSViewPlatformViewDefinition: PlatformViewDefinition, @unchecked Sendable {
1414
override final class var system: PlatformViewDefinition.System { .nsView }
1515

16-
#if _OPENSWIFTUI_SWIFTUI_RENDER
17-
override static func makeView(kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject {
18-
_makeView(kind: kind.pointee)
19-
}
20-
21-
override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject {
22-
preconditionFailure("TODO")
23-
}
24-
#else
2516
override static func makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject {
26-
_makeView(kind: kind)
17+
// TODO
18+
return NSView()
2719
}
2820

29-
override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject {
21+
override static func makeLayerView(type: CALayer.Type, kind: PlatformViewDefinition.ViewKind) -> AnyObject {
3022
preconditionFailure("TODO")
3123
}
32-
#endif
33-
34-
// FIXME: A shim for _OPENSWIFTUI_SWIFTUI_RENDER
35-
private static func _makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject {
36-
// TODO
37-
return NSView()
38-
}
3924
}
4025
#endif

Sources/OpenSwiftUI/Integration/Render/UIKit/UIViewPlatformViewDefinition.swift

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,7 @@ import OpenSwiftUISymbolDualTestsSupport
1515
final class UIViewPlatformViewDefinition: PlatformViewDefinition, @unchecked Sendable {
1616
override final class var system: PlatformViewDefinition.System { .uiView }
1717

18-
#if _OPENSWIFTUI_SWIFTUI_RENDER
19-
override static func makeView(kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject {
20-
_makeView(kind: kind.pointee)
21-
}
22-
23-
override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject {
24-
preconditionFailure("TODO")
25-
}
26-
#else
2718
override static func makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject {
28-
_makeView(kind: kind)
29-
}
30-
31-
override static func makeLayerView(type: CALayer.Type, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject {
32-
preconditionFailure("TODO")
33-
}
34-
#endif
35-
36-
// FIXME: A shim for _OPENSWIFTUI_SWIFTUI_RENDER
37-
private static func _makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject {
3819
let view: UIView
3920
switch kind {
4021
case .mask:
@@ -48,6 +29,10 @@ final class UIViewPlatformViewDefinition: PlatformViewDefinition, @unchecked Sen
4829
return view
4930
}
5031

32+
override static func makeLayerView(type: CALayer.Type, kind: PlatformViewDefinition.ViewKind) -> AnyObject {
33+
preconditionFailure("TODO")
34+
}
35+
5136
private static func initView(_ view: UIView, kind: PlatformViewDefinition.ViewKind) {
5237
if kind != .platformView && kind != .platformGroup {
5338
view.autoresizesSubviews = false

Sources/OpenSwiftUI/Scene/Core/Scene.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55
// Audited for iOS 15.5
66
// Status: Empty
77

8+
#if canImport(CoreTransferable)
9+
import CoreTransferable
10+
#endif
11+
812
public protocol Scene {
913
associatedtype Body: Scene
1014

1115
@SceneBuilder
1216
var body: Self.Body { get }
1317
// static func _makeScene(scene: _GraphValue<Self>, inputs: _SceneInputs) -> _SceneOutputs
1418
}
19+
1520
extension Never: Scene {}
1621

1722
extension Scene {

Sources/OpenSwiftUICore/Render/DisplayList/DisplayListViewRenderer.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ extension DisplayList {
102102
@_silgen_name("OpenSwiftUITestStub_DisplayListViewRendererRenderRootView")
103103
package func swiftUI_render(
104104
rootView: AnyObject,
105-
from list: UnsafePointer<DisplayList>,
106-
time: UnsafePointer<Time>,
107-
nextTime: UnsafePointer<Time>,
108-
version: UnsafePointer<DisplayList.Version>,
109-
maxVersion: UnsafePointer<DisplayList.Version>,
110-
environment: UnsafePointer<DisplayList.ViewRenderer.Environment>
105+
from list: DisplayList,
106+
time: Time,
107+
nextTime: Time,
108+
version: DisplayList.Version,
109+
maxVersion: DisplayList.Version,
110+
environment: DisplayList.ViewRenderer.Environment
111111
) -> Time
112112
#endif
113113

Sources/OpenSwiftUICore/Render/PlatformViewDefinition.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,11 @@ open class PlatformViewDefinition: @unchecked Sendable {
5050
}
5151

5252
open class var system: PlatformViewDefinition.System { .init(base: .swiftUIView) }
53-
54-
#if _OPENSWIFTUI_SWIFTUI_RENDER
55-
open class func makeView(kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject { preconditionFailure("") }
56-
#if canImport(Darwin)
57-
open class func makeLayerView(type: CALayer.Type, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) -> AnyObject { preconditionFailure("") }
58-
#endif
59-
open class func makePlatformView(view: AnyObject, kind: UnsafePointer<PlatformViewDefinition.ViewKind>) { preconditionFailure("") }
60-
#else
6153
open class func makeView(kind: PlatformViewDefinition.ViewKind) -> AnyObject { preconditionFailure("") }
6254
#if canImport(Darwin)
6355
open class func makeLayerView(type: CALayer.Type, kind: PlatformViewDefinition.ViewKind) -> AnyObject { preconditionFailure("") }
6456
#endif
6557
open class func makePlatformView(view: AnyObject, kind: PlatformViewDefinition.ViewKind) { preconditionFailure("") }
66-
#endif
6758
open class func makeDrawingView(options: PlatformDrawableOptions) -> any PlatformDrawable { preconditionFailure("") }
6859
open class func setPath(_ path: Path, shapeView: AnyObject) { preconditionFailure("") }
6960
open class func setProjectionTransform(_ transform: ProjectionTransform, projectionView: AnyObject) { preconditionFailure("") }

Sources/OpenSwiftUICore/View/IDView.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ extension View {
5353
extension IDView {
5454
@usableFromInline
5555
package static func _makeView(view: _GraphValue<Self>, inputs: _ViewInputs) -> _ViewOutputs {
56-
if _SemanticFeature_v2.isEnabled {
57-
return makeImplicitRoot(view: view, inputs: inputs)
58-
} else {
56+
// FIXME: makeImplicitRoot is not implemented yet
57+
// if _SemanticFeature_v2.isEnabled {
58+
// return makeImplicitRoot(view: view, inputs: inputs)
59+
// } else {
5960
let id = view.value[offset: { .of(&$0.id) }]
6061
let phase = IDPhase(id: id, phase: inputs.viewPhase, lastID: nil, delta: 0)
6162
var inputs = inputs
6263
inputs.viewPhase = Attribute(phase)
6364
return Content.makeDebuggableView(view: view[offset: { .of(&$0.content)}], inputs: inputs)
64-
}
65+
// }
6566
}
6667
}
6768

Tests/OpenSwiftUICompatibilityTests/SwiftUICore/Modifier/ViewModifier/AppearanceActionModifierTests.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ struct AppearanceActionModifierTests {
3434
#endif
3535
}
3636

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

0 commit comments

Comments
 (0)