-
Notifications
You must be signed in to change notification settings - Fork 79
Add stdout renderer support #893
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
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1f198aa
Add stdout renderer config
Kyle-Ye b323478
Update DisplayListViewRenderer
Kyle-Ye 85cf93c
Add DisplayListStdoutRenderer
Kyle-Ye a7334c3
Add rendererConfiguration to App
Kyle-Ye 9613c21
Add StdoutRendererHost
Kyle-Ye 01e5e79
Add runStdoutApp
Kyle-Ye aedbfbb
Add Stdout Example App
Kyle-Ye e5ad5ae
Add run-example for Stdout
Kyle-Ye 240f155
Fix app impl
Kyle-Ye 93dd17f
Update App.rendererConfiguration
Kyle-Ye 0802b27
Add open-xcode for Stdout
Kyle-Ye 45b09f1
Configure Stdout renderer Xcode workflow
Kyle-Ye 8a7ae78
Update tuist config
Kyle-Ye 5c6d740
Fix Linux run-example
Kyle-Ye 0f21d9d
Add std_renderer job
Kyle-Ye 6630171
Disable Linux temporary
Kyle-Ye 01016d3
Fix stdout renderer Linux imports
Kyle-Ye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: Stdout Renderer | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| # Disable on Linux for now | ||
| # stdout_renderer_linux: | ||
| # name: Run stdout renderer on Linux | ||
| # runs-on: ubuntu-22.04 | ||
| # container: swift:6.1.0-jammy | ||
| # env: | ||
| # OPENSWIFTUI_WERROR: 0 | ||
| # OPENSWIFTUI_SWIFT_LOG: 1 | ||
| # OPENSWIFTUI_SWIFT_CRYPTO: 1 | ||
| # steps: | ||
| # - uses: actions/checkout@v4 | ||
| # - name: Toolchain fix patch | ||
| # run: | | ||
| # # Fix swift-corelibs-foundation#5211 | ||
| # .github/scripts/fix-toolchain.sh | ||
| # - name: Run stdout renderer example | ||
| # run: Renderer/Stdout/run-example.sh | ||
|
|
||
| stdout_renderer_macos: | ||
| name: Run stdout renderer on macOS | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [macos-15] | ||
| xcode-version: ["16.4"] | ||
| release: [2024] | ||
| runs-on: | ||
| - self-hosted | ||
| - ${{ matrix.os }} | ||
| env: | ||
| OPENSWIFTUI_WERROR: 0 | ||
| OPENSWIFTUI_TARGET_RELEASE: ${{ matrix.release }} | ||
| OPENSWIFTUI_USE_LOCAL_DEPS: 1 | ||
| GH_TOKEN: ${{ github.token }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup Xcode | ||
| uses: OpenSwiftUIProject/setup-xcode@v2 | ||
| with: | ||
| xcode-version: ${{ matrix.xcode-version }} | ||
| - name: Set up build environment | ||
| run: Scripts/CI/darwin_setup_build.sh | ||
| shell: bash | ||
| - name: Run stdout renderer example | ||
| run: Renderer/Stdout/run-example.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Renderers | ||
|
|
||
| This directory contains renderer-specific examples and helper packages that are | ||
| kept outside the main OpenSwiftUI package manifest. | ||
|
|
||
| ## Stdout | ||
|
|
||
| `Stdout/` contains a small executable package that launches an OpenSwiftUI app | ||
| with the stdout renderer enabled. It is useful for checking display-list output | ||
| without adding demo targets to the main package. | ||
|
|
||
| Run it from this repository: | ||
|
|
||
| ```sh | ||
| cd Renderer/Stdout | ||
| ./run-example.sh | ||
| ``` | ||
|
|
||
| On macOS, use the Stdout Tuist project for Xcode runs. | ||
|
|
||
| ```sh | ||
| cd Renderer/Stdout | ||
| ./open-xcode.sh | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| .build | ||
| .swiftpm | ||
| .xcodebuild | ||
| Derived | ||
| Package.resolved | ||
| xcodebuild.log | ||
| *.xcodeproj | ||
| *.xcworkspace | ||
| Tuist/.build | ||
| Tuist/.swiftpm | ||
| Tuist/Dependencies |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| @_spi(StdoutRenderer) import OpenSwiftUI | ||
|
|
||
| @main | ||
| struct ExampleApp: App { | ||
| static var rendererConfiguration: _RendererConfiguration? { .stdout() } | ||
|
|
||
| var body: some Scene { | ||
| WindowGroup { | ||
| VStack(spacing: 10.0) { | ||
| Color.red | ||
| Color.blue | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // swift-tools-version: 6.1 | ||
|
|
||
| import PackageDescription | ||
|
|
||
| let package = Package( | ||
| name: "StdoutRenderer", | ||
| platforms: [.macOS(.v15)], | ||
| products: [ | ||
| .executable(name: "ExampleApp", targets: ["ExampleApp"]), | ||
| ], | ||
| dependencies: [ | ||
| .package(path: "../.."), | ||
| ], | ||
| targets: [ | ||
| .executableTarget( | ||
| name: "ExampleApp", | ||
| dependencies: [ | ||
| .product(name: "OpenSwiftUI", package: "OpenSwiftUI"), | ||
| ], | ||
| path: "ExampleApp" | ||
| ), | ||
| ] | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import ProjectDescription | ||
|
|
||
| let appName = "StdoutRendererDemo" | ||
|
|
||
| let debugBuildSettings: SettingsDictionary = [ | ||
| "ALWAYS_SEARCH_USER_PATHS": "NO", | ||
| "GCC_OPTIMIZATION_LEVEL": "0", | ||
| "ONLY_ACTIVE_ARCH": "YES", | ||
| "SWIFT_COMPILATION_MODE": "singlefile", | ||
| "SWIFT_OPTIMIZATION_LEVEL": "-Onone", | ||
| ] | ||
|
|
||
| let releaseBuildSettings: SettingsDictionary = [ | ||
| "SWIFT_COMPILATION_MODE": "wholemodule", | ||
| "SWIFT_OPTIMIZATION_LEVEL": "-O", | ||
| ] | ||
|
|
||
| let appSettings: SettingsDictionary = [ | ||
| "CODE_SIGN_STYLE": "Automatic", | ||
| "DEVELOPMENT_TEAM": "", | ||
| "ENABLE_HARDENED_RUNTIME": "YES", | ||
| "FRAMEWORK_SEARCH_PATHS": [ | ||
| "$(inherited)", | ||
| "$(BUILD_DIR)/Debug$(EFFECTIVE_PLATFORM_NAME)", | ||
| "$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)", | ||
| ], | ||
| "GENERATE_INFOPLIST_FILE": "YES", | ||
| "LD_RUNPATH_SEARCH_PATHS": [ | ||
| "$(inherited)", | ||
| "@executable_path/../Frameworks", | ||
| ], | ||
| "LIBRARY_SEARCH_PATHS": [ | ||
| "$(inherited)", | ||
| "$(BUILD_DIR)/Debug$(EFFECTIVE_PLATFORM_NAME)", | ||
| "$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)", | ||
| ], | ||
| "PRODUCT_BUNDLE_IDENTIFIER": "org.OpenSwiftUIProject.OpenSwiftUI.StdoutRendererDemo", | ||
| "SWIFT_VERSION": "5.0", | ||
| ] | ||
|
|
||
| let privateFrameworkDependencies: [TargetDependency] = [ | ||
| .external(name: "AttributeGraph"), | ||
| .external(name: "RenderBox"), | ||
| .external(name: "CoreUI"), | ||
| .external(name: "CoreSVG"), | ||
| .external(name: "SFSymbols"), | ||
| ] | ||
|
|
||
| let target = Target.target( | ||
| name: appName, | ||
| destinations: [.mac], | ||
| product: .app, | ||
| bundleId: "org.OpenSwiftUIProject.OpenSwiftUI.StdoutRendererDemo", | ||
| deploymentTargets: .macOS("15.0"), | ||
| infoPlist: .extendingDefault(with: [:]), | ||
| sources: [ | ||
| "ExampleApp/**/*.swift", | ||
| ], | ||
| dependencies: [ | ||
| .external(name: "OpenSwiftUI"), | ||
| ] + privateFrameworkDependencies, | ||
| settings: .settings( | ||
| base: appSettings, | ||
| configurations: [ | ||
| .debug(name: "Debug", settings: debugBuildSettings), | ||
| .release(name: "Release", settings: releaseBuildSettings), | ||
| ], | ||
| defaultSettings: .none | ||
| ) | ||
| ) | ||
|
|
||
| let scheme = Scheme.scheme( | ||
| name: appName, | ||
| shared: true, | ||
| buildAction: .buildAction(targets: [.target(appName)]), | ||
| runAction: .runAction( | ||
| configuration: "Debug", | ||
| executable: .executable(.target(appName)) | ||
| ), | ||
| archiveAction: .archiveAction(configuration: "Release"), | ||
| profileAction: .profileAction( | ||
| configuration: "Release", | ||
| executable: .executable(.target(appName)) | ||
| ), | ||
| analyzeAction: .analyzeAction(configuration: "Debug") | ||
| ) | ||
|
|
||
| let project = Project( | ||
| name: "StdoutRenderer", | ||
| options: .options( | ||
| automaticSchemesOptions: .disabled, | ||
| developmentRegion: "en" | ||
| ), | ||
| settings: .settings( | ||
| configurations: [ | ||
| .debug(name: "Debug", settings: debugBuildSettings), | ||
| .release(name: "Release", settings: releaseBuildSettings), | ||
| ], | ||
| defaultSettings: .none, | ||
| defaultConfiguration: "Debug" | ||
| ), | ||
| targets: [ | ||
| target, | ||
| ], | ||
| schemes: [ | ||
| scheme, | ||
| ], | ||
| additionalFiles: [ | ||
| "README.md", | ||
| "Package.swift", | ||
| "run-example.sh", | ||
| ] | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Stdout Renderer | ||
|
|
||
| This directory contains a minimal OpenSwiftUI app with the stdout renderer | ||
| enabled. The Swift package depends on the local OpenSwiftUI checkout at `../..`. | ||
|
|
||
| ## CLI | ||
|
|
||
| ```sh | ||
| ./run-example.sh | ||
| ``` | ||
|
|
||
| The script selects AttributeGraph on macOS and Compute on other platforms, | ||
| then runs `swift run ExampleApp`. | ||
|
|
||
| ## macOS Xcode | ||
|
|
||
| Use the Tuist project when running the demo from Xcode on macOS: | ||
|
|
||
| ```sh | ||
| ./open-xcode.sh | ||
| ``` | ||
|
|
||
| The script runs `tuist install`, generates the workspace without opening during | ||
| generation, then opens `StdoutRenderer.xcworkspace`. If `mise` is available, the | ||
| script uses the repository-pinned Tuist version. | ||
|
|
||
| The Tuist project uses local OpenSwiftUI, OpenAttributeGraph, OpenRenderBox, | ||
| and DarwinPrivateFrameworks dependencies so Xcode does not need to open the | ||
| Swift package directly. Its package settings mirror the generated Example | ||
| project's local OpenSwiftUI product destinations, keeping AttributeGraph | ||
| enabled on macOS while preserving valid generated target platforms. | ||
|
|
||
| The example configures the app renderer with: | ||
|
|
||
| ```swift | ||
| @_spi(StdoutRenderer) import OpenSwiftUI | ||
|
|
||
| static var rendererConfiguration: _RendererConfiguration? { .stdout() } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import ProjectDescription | ||
|
|
||
| let tuist = Tuist( | ||
| project: .tuist( | ||
| generationOptions: .options( | ||
| defaultConfiguration: "Debug", | ||
| manifestEnvironment: [ | ||
| "DARWINPRIVATEFRAMEWORKS_*", | ||
| "OPENATTRIBUTEGRAPH_*", | ||
| "OPENRENDERBOX_*", | ||
| "OPENSWIFTUI_*", | ||
| ] | ||
| ) | ||
| ) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // swift-tools-version: 6.1 | ||
|
|
||
| import PackageDescription | ||
|
|
||
| let package = Package( | ||
| name: "StdoutRendererDependencies", | ||
| dependencies: [ | ||
| .package(path: "../../.."), | ||
| .package(path: "../../../../OpenAttributeGraph"), | ||
| .package(path: "../../../../OpenRenderBox"), | ||
| .package(path: "../../../../DarwinPrivateFrameworks"), | ||
| .package(url: "https://github.com/OpenSwiftUIProject/SymbolLocator.git", from: "0.2.0"), | ||
| .package(url: "https://github.com/apple/swift-collections", from: "1.1.0"), | ||
| .package(url: "https://github.com/apple/swift-numerics", from: "1.0.3"), | ||
| .package(url: "https://github.com/swiftlang/swift-syntax.git", from: "601.0.0"), | ||
| ] | ||
| ) | ||
|
|
||
| #if TUIST | ||
| import ProjectDescription | ||
|
|
||
| let packageDestinations: Destinations = [.mac] | ||
|
|
||
| let packageProductTypes: [String: ProjectDescription.Product] = [ | ||
| "OpenSwiftUI": .framework, | ||
| "OpenSwiftUICore": .staticFramework, | ||
| "OpenSwiftUI_SPI": .staticFramework, | ||
| "COpenSwiftUI": .staticFramework, | ||
| "OpenSwiftUIMacros": .macro, | ||
| "OpenSwiftUITestsSupport": .staticFramework, | ||
| "OpenSwiftUISymbolDualTestsSupport": .staticFramework, | ||
| "OpenAttributeGraphShims": .staticFramework, | ||
| "OpenCoreGraphicsShims": .staticFramework, | ||
| "OpenObservation": .staticFramework, | ||
| "OpenQuartzCoreShims": .staticFramework, | ||
| "OpenRenderBoxShims": .staticFramework, | ||
| "AttributeGraph": .framework, | ||
| "RenderBox": .framework, | ||
| "CoreUI": .framework, | ||
| "CoreSVG": .framework, | ||
| "SFSymbols": .framework, | ||
| "BacklightServices": .framework, | ||
| "SymbolLocator": .staticFramework, | ||
| ] | ||
|
|
||
| let packageProductDestinations: [String: Destinations] = [ | ||
| "OpenSwiftUI": packageDestinations, | ||
| "OpenSwiftUICore": packageDestinations, | ||
| "OpenSwiftUI_SPI": packageDestinations, | ||
| "OpenSwiftUIExtension": packageDestinations, | ||
| "OpenSwiftUIBridge": packageDestinations, | ||
| "OpenSwiftUITestsSupport": packageDestinations, | ||
| "OpenSwiftUISymbolDualTestsSupport": packageDestinations, | ||
| "OpenAttributeGraph": packageDestinations, | ||
| "OpenAttributeGraphShims": packageDestinations, | ||
| "OpenRenderBox": packageDestinations, | ||
| "OpenRenderBoxShims": packageDestinations, | ||
| "AttributeGraph": packageDestinations, | ||
| "RenderBox": packageDestinations, | ||
| "CoreUI": packageDestinations, | ||
| "CoreSVG": packageDestinations, | ||
| "SFSymbols": packageDestinations, | ||
| "SymbolLocator": packageDestinations, | ||
| ] | ||
|
|
||
| let debugBuildSettings: SettingsDictionary = [ | ||
| "ALWAYS_SEARCH_USER_PATHS": "NO", | ||
| "GCC_OPTIMIZATION_LEVEL": "0", | ||
| "ONLY_ACTIVE_ARCH": "YES", | ||
| "SWIFT_COMPILATION_MODE": "singlefile", | ||
| "SWIFT_OPTIMIZATION_LEVEL": "-Onone", | ||
| ] | ||
|
|
||
| let releaseBuildSettings: SettingsDictionary = [ | ||
| "SWIFT_COMPILATION_MODE": "wholemodule", | ||
| "SWIFT_OPTIMIZATION_LEVEL": "-O", | ||
| ] | ||
|
|
||
| let packageSettings = PackageSettings( | ||
| productTypes: packageProductTypes, | ||
| productDestinations: packageProductDestinations, | ||
| baseSettings: .settings( | ||
| configurations: [ | ||
| .debug(name: "Debug", settings: debugBuildSettings), | ||
| .release(name: "Release", settings: releaseBuildSettings), | ||
| ], | ||
| defaultSettings: .none, | ||
| defaultConfiguration: "Debug" | ||
| ) | ||
| ) | ||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renderer/Stdout/README.md:24-25The README saysopen-xcode.shusesmiseto pick a repo-pinned Tuist version, but the script currently callstuistdirectly. This looks like a doc/code mismatch that could confuse users trying to reproduce the intended workflow.Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.