Skip to content

Commit 899460f

Browse files
authored
Enable OSUI ViewRenderer by default (#872)
1 parent 0674dc5 commit 899460f

16 files changed

Lines changed: 131 additions & 41 deletions

File tree

.github/workflows/uitests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ jobs:
168168
OPENSWIFTUI_TARGET_RELEASE: ${{ matrix.release }}
169169
OPENSWIFTUI_USE_LOCAL_DEPS: 1
170170
OPENSWIFTUI_LINK_TESTING: 0
171+
OPENSWIFTUI_SWIFTUI_RENDERER: 1 # TODO: Add render-off UI test coverage with OPENSWIFTUI_SWIFTUI_RENDERER=0.
171172
GH_TOKEN: ${{ github.token }}
172173
steps:
173174
- name: Mark PR status running
@@ -258,6 +259,7 @@ jobs:
258259
OPENSWIFTUI_SWIFT_CRYPTO: 0
259260
OPENSWIFTUI_TARGET_RELEASE: ${{ matrix.release }}
260261
OPENSWIFTUI_USE_LOCAL_DEPS: 1
262+
OPENSWIFTUI_SWIFTUI_RENDERER: 1 # TODO: Add render-off UI test coverage with OPENSWIFTUI_SWIFTUI_RENDERER=0.
261263
GH_TOKEN: ${{ github.token }}
262264
steps:
263265
- name: Mark PR status running

INTEGRATION.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ This guide walks you through the steps to integrate OpenSwiftUI into your projec
66

77
- Xcode 16.4
88
- Swift 6.1.2+
9-
- macOS 15.5 (for macOS apps) or iOS 18.5 (for iOS apps)
109

1110
## Important Notes
1211

@@ -186,17 +185,17 @@ Currently, AttributeGraph is missing some symbols for iOS device. Until OpenAttr
186185

187186
**Future resolution:** This limitation will be lifted when OpenAttributeGraph is ready, which will unlock iOS device platform support.
188187

189-
### 2. ABI Compatibility Requirements
188+
### 2. Optional SwiftUI Renderer ABI Compatibility
190189

191-
⚠️ **Important:** The current Render engine uses a private API of SwiftUI which does not guarantee ABI stability. Until OpenSwiftUI's ViewUpdater render engine is implemented, it is required to use the same ABI version.
190+
By default, OpenSwiftUI does not require a specific SwiftUI renderer ABI version.
192191

193-
**Current supported ABI versions:**
194-
- **iOS 18.5**
195-
- **macOS 15.5**
192+
The ABI limitation only applies when you explicitly opt into the SwiftUI renderer by setting `OPENSWIFTUI_SWIFTUI_RENDERER=1`. That renderer uses private SwiftUI APIs which do not guarantee ABI stability.
196193

197-
**Impact:** Your target platform deployment version must match these specific versions to avoid runtime compatibility issues.
194+
**Current supported SwiftUI renderer ABI versions:**
195+
- **iOS 18.5 to before iOS 26.0**
196+
- **macOS 15.5 to before macOS 26.0**
198197

199-
**Future resolution:** This limitation will be lifted when OpenSwiftUI's own Render engine (ViewUpdater) is ready, which will remove the ABI version lock requirement and allow broader platform version support.
198+
**Impact:** If `OPENSWIFTUI_SWIFTUI_RENDERER=1` is enabled, your runtime platform version must be in the supported range to avoid runtime compatibility issues.
200199

201200
## Troubleshooting
202201

@@ -214,4 +213,4 @@ Make sure you've added the AttributeGraph.xcframework to your target and set it
214213
If Xcode fails to resolve the package:
215214
1. Make sure you're using `branch: "main"` or a specific `revision:` instead of a version tag
216215
2. Try **File → Packages → Reset Package Caches**
217-
3. Clean the build folder (**Shift+Cmd+K**) and rebuild
216+
3. Clean the build folder (**Shift+Cmd+K**) and rebuild

Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ let swiftLogCondition = envBoolValue("SWIFT_LOG", default: !buildForDarwinPlatfo
171171
let swiftCryptoCondition = envBoolValue("SWIFT_CRYPTO", default: !buildForDarwinPlatform)
172172
let renderGTKCondition = envBoolValue("RENDER_GTK", default: !buildForDarwinPlatform)
173173

174-
let swiftUIRenderCondition = envBoolValue("SWIFTUI_RENDER", default: buildForDarwinPlatform)
174+
let swiftUIRenderCondition = envBoolValue("SWIFTUI_RENDERER", default: false)
175175

176176
let ignoreAvailability = envBoolValue("IGNORE_AVAILABILITY", default: !isSPIDocGenerationBuild && !compatibilityTestCondition)
177177

@@ -291,9 +291,9 @@ if linkBacklightServices {
291291
}
292292

293293
if swiftUIRenderCondition {
294-
sharedCSettings.append(.define("_OPENSWIFTUI_SWIFTUI_RENDER"))
295-
sharedCxxSettings.append(.define("_OPENSWIFTUI_SWIFTUI_RENDER"))
296-
sharedSwiftSettings.append(.define("_OPENSWIFTUI_SWIFTUI_RENDER"))
294+
sharedCSettings.append(.define("OPENSWIFTUI_SWIFTUI_RENDERER", .when(platforms: .darwinPlatforms)))
295+
sharedCxxSettings.append(.define("OPENSWIFTUI_SWIFTUI_RENDERER", .when(platforms: .darwinPlatforms)))
296+
sharedSwiftSettings.append(.define("OPENSWIFTUI_SWIFTUI_RENDERER", .when(platforms: .darwinPlatforms)))
297297
}
298298

299299
if linkTesting {

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ for various platforms:
104104
| **Android** | None | Not supported yet |||| |
105105
| **Windows** | None | Not supported yet |||| |
106106

107-
[^1]: AppKit intergration is partly implemented. Render is support via SwiftUI's render implementation. Other UI framework backend is not intergrated yet.
107+
[^1]: AppKit intergration is partly implemented. Other UI framework backend is not intergrated yet.
108108

109-
[^2]: UIKit intergration is partly implemented. Render is support via SwiftUI's render implementation.
109+
[^2]: UIKit intergration is partly implemented.
110110

111111
[^3]: Build and test is supported. But some feature is cut due to known Swift compiler issue.
112112

Scripts/build_xcframework.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ set -e
44

55
: "${OPENSWIFTUI_LIBRARY_TYPE:=dynamic}"
66
: "${OPENSWIFTUI_USE_LOCAL_DEPS:=1}"
7+
: "${OPENSWIFTUI_SWIFTUI_RENDERER:=0}"
78
export OPENSWIFTUI_LIBRARY_TYPE
89
export OPENSWIFTUI_USE_LOCAL_DEPS
10+
export OPENSWIFTUI_SWIFTUI_RENDERER
11+
# TODO: replace AG with Compute or OAG by default
912

1013
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
1114
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import OpenAttributeGraphShims
1212
@_spi(ForOpenSwiftUIOnly)
1313
@_spi(Private)
1414
public import OpenSwiftUICore
15-
#if _OPENSWIFTUI_SWIFTUI_RENDER
15+
#if OPENSWIFTUI_SWIFTUI_RENDERER
1616
import OpenSwiftUISymbolDualTestsSupport
1717
#endif
1818
import COpenSwiftUI

Sources/OpenSwiftUI/Render/DisplayList/AppKitDisplayList.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@_spi(DisplayList_ViewSystem)
1212
import OpenSwiftUICore
1313
import AppKit
14-
#if _OPENSWIFTUI_SWIFTUI_RENDER
14+
#if OPENSWIFTUI_SWIFTUI_RENDERER
1515
import OpenSwiftUISymbolDualTestsSupport
1616
#endif
1717
import COpenSwiftUI

Sources/OpenSwiftUI/Render/DisplayList/UIKitDisplayList.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import COpenSwiftUI
1111
@_spi(DisplayList_ViewSystem) import OpenSwiftUICore
1212
import UIKit
13-
#if _OPENSWIFTUI_SWIFTUI_RENDER
13+
#if OPENSWIFTUI_SWIFTUI_RENDERER
1414
import OpenSwiftUISymbolDualTestsSupport
1515
#endif
1616
import QuartzCore_Private

Sources/OpenSwiftUICore/Graphic/GraphicsContext.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,13 @@ public struct GraphicsContext {
523523
}
524524

525525
extension GraphicsContext {
526-
#if canImport(Darwin) && _OPENSWIFTUI_SWIFTUI_RENDER
526+
#if OPENSWIFTUI_SWIFTUI_RENDERER
527527
@_silgen_name("OpenSwiftUITestStub_GraphicsContextDrawPathWithShadingAndStyle")
528528
private func swiftUI_draw(_ path: Path, with shading: GraphicsContext.ResolvedShading, style: PathDrawingStyle)
529529
#endif
530530

531531
package func draw(_ path: Path, with shading: GraphicsContext.ResolvedShading, style: PathDrawingStyle) {
532-
#if canImport(Darwin) && _OPENSWIFTUI_SWIFTUI_RENDER
532+
#if OPENSWIFTUI_SWIFTUI_RENDERER
533533
swiftUI_draw(path, with: shading, style: style)
534534
#else
535535
_openSwiftUIUnimplementedWarning()

0 commit comments

Comments
 (0)