-
-
Notifications
You must be signed in to change notification settings - Fork 23.8k
SwiftUI lifecycle for Apple embedded platforms #109974
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
SwiftUI lifecycle for Apple embedded platforms #109974
Conversation
0438c42 to
a7706c9
Compare
stuartcarnie
left a comment
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.
This is great work, @rsanchezsaez and really appreciate you adding support to SCons to handle Swift files and C++ interop! The changes a minimally invasive, which is awesome!
|
|
||
| if (GLOBAL_GET("display/window/ios/allow_high_refresh_rate")) { | ||
| self.displayLink.preferredFramesPerSecond = 120; | ||
| } else { | ||
| self.displayLink.preferredFramesPerSecond = 60; | ||
| } | ||
| self.displayLink.preferredFramesPerSecond = self.preferredFrameRate; |
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.
Note
This has been moved to iOS (iPhone / iPad) specific implementation, as visionOS has different requirements (90 fps)
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.
I experimented with implementing a whole SCons module for adding Swift support. I think @rsanchezsaez's solution is totally fine. For other reviewers, essentially what it does is combine all .swift files into a single static library and Swift module. Swift has really great Objective-C and C++ interop, so it just works.
@akien-mga as expected, our builder will need to add the Swift compiler toolchain to be able to build these files. Swift is supported on Linux and Windows, so the toolchain is available, but it is unclear how much work I'll need to do to get it running on the Linux builder containers. I can certainly try.
The alternative is that Godot may wish to consider a dedicated machine running macOS for all the Apple builds, which would simplify our build process immensely. Getting it all working on Linux, particularly visionOS, was esoteric and I even patched the Clang toolchain to fix a bug processing visionOS availability via iOS availability attributes. I imagine the number of people able to support that work is relatively small…
- Introduces a SCons builder for Swift files - Increases the minimum deployment targets to iOS 14.0, and visionOS 26.0. - Replaces manually UIWindow management by a SwiftUI instantiated app.
6a8e24d to
038f593
Compare
Repiteo
left a comment
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.
This isn't the most "SCons" implementation, but neither is most of this repo so that's not exactly a blocker. Similarly, implementation-specific methods should ideally be relegated to implementation-specific locations, but the repo is also violating that (including the function directly preceeding setup_swift_builder())
I think we're safe to integrate this as-is!
|
Thanks! |
Dear Godot community,
This PR is a followup to #105628 (I encourage you to read the description of that PR, where I outlined the plan, to get the full context for this contribution).
This change adds Swift compilation support to SCons, and adopts the SwiftUI lifecycle on Apple embedded platforms, which is the modern way of instantiating apps on Apple platforms. This is a pre-requesite for launching an immersive scene on visionOS.
This PR builds on top of #107789, so that one should be merged first.
cc @BastiaanOlij @stuartcarnie @bruvzg
Technical Discussion
I have developed and tested these changes using Xcode 26 beta 6 (17A5305f).
Minimum Deployment Targets
This PR increases the minimum deployment targets to iOS 14.0 (which is the minimum supported version for SwiftUI app lifecycle), and visionOS 26.0. We believe increasing the iOS target to 14.0 is acceptable given the age of that release.
SCons
There are parts of SCons I don't understand very well, and the current approach for compiling Swift is based on trial and error. I think the way the Builder is implemented a bit unorthodox, because Swift projects don't have header files, so you must pass all Swift files to the compiler.
I have tested that if there are more than one Swift file in the same subfolder, the are compiled and linked successfully.
If any SCons experts have suggestions for improving this aspect, we'd be happy to iterate on the solution.
Testing
We have been testing this PR with the Platformer demo project. We have verified the project continues to work on iOS and visionOS, both with the Mobile and Forward+ renderers using the Metal rendering driver.
Missing Functionality