fix(ios): don't register iOS 26 only method in protocol block - #1301
Merged
Conversation
velocitysystems
force-pushed
the
ios18-objc2-crash
branch
from
August 6, 2026 20:34
705f869 to
20c40d0
Compare
velocitysystems
marked this pull request as ready for review
August 6, 2026 20:52
FabianLars
approved these changes
Aug 7, 2026
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1300.
Problem
preferredWindowingControlStyleForScene:(#1250, #1276) is an iOS 26 selector declared inside theunsafe impl UIWindowSceneDelegateblock. objc2 validates protocol-block selectors against the runtime protocol, and iOS 18'sUIWindowSceneDelegatedoesn't declare it, so class registration panics on launch:The check is
#[cfg(debug_assertions)], so this is debug builds only — release builds register the method and iOS 18 simply never calls it. It breakscargo tauri ios devon iOS 18.Fix
Empty the protocol block and register the method from a plain
impl, which performs no protocol lookup.unsafe impl UISceneDelegateis untouched.The resulting class is unchanged, verified against objc2 0.6.4:
add_protocol()runs independently of any methods, so conformance survives the empty block;builder.add_method()sits outside thedebug_assertionscheck in both paths, so iOS 26 still resolves the selector; andfinish()only checks required methods, of whichUIWindowSceneDelegatehas none.Trade-off: gives up objc2's typo check on this one selector.
Why not the build-script gate from wry#1781
That fix reads the build host's OS version and cfg-gates the method out, which works on macOS because the host is the runtime. On iOS it isn't — the host is macOS and the runtime is a separate simulator or device. Since Xcode 26 is needed to compile this selector at all, the host check would pass and the panic would remain. The only iOS-side build-time signal is the deployment target, which is a floor rather than the runtime version, so gating on it reduces to
#[cfg(not(debug_assertions))]— losing.minimalwindowing controls on iPadOS 26 in every debug build while checking nothing, since the check only runs in debug and the method would be absent there.Also considered:
[profile.dev.package.objc2] debug-assertions = false(objc2#796) works, but cargo only honours profiles from the workspace root, so tao can't ship it. objc2'sdisable-encoding-assertionsfeature doesn't cover__macro_helpers/define_class.rs. Remaining alternatives are in #1300.Includes a
TODOto move the method back into the protocol block once objc2 0.7.0 fixes the check (objc2#645).Testing
cargo check --target aarch64-apple-iosandcargo testpass.