refactor(screen-orientation): remove unneeded iOS code - #2589
Open
andredestro wants to merge 1 commit into
Open
Conversation
The plugin's deployment target is iOS 16.0, so the `#available(iOS 16.0, *)` checks always pass and their fallback branches were unreachable: - `lockLegacy(_:)`, which set the orientation through KVC on `UIDevice` and called `attemptRotationToDeviceOrientation()`, deprecated in iOS 16 - the `attemptRotationToDeviceOrientation()` fallback in `unlock` Removing them clears the only deprecation warning in the iOS build. The remaining geometry update was duplicated between `lock` and `unlock`, so it now lives in a single `requestGeometryUpdate(_:completion:)` helper. That also fixes the completion being called twice: `completion(nil)` ran unconditionally right after the request was made, so a failure resolved the call before rejecting it. The error handler only runs when the request is rejected, so its result is now reported once, after the request.
andredestro
requested review from
ItsChaceD,
OS-pedrogustavobilro,
OS-ruimoreiramendes,
alexgerardojacinto,
jcesarmobile,
markemer and
theproducer
August 20, 2026 13:26
|
Released dev build of screen-orientation with dev version: 9.0.0-dev-2589-20260820T132634.0 |
jcesarmobile
approved these changes
Aug 21, 2026
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.
The plugin's deployment target is iOS 16.0 (
Package.swiftand the podspec), so the two#available(iOS 16.0, *)checks inScreenOrientation.swiftalways pass and their fallback branches were unreachable.Removed
lockLegacy(_:), which set the orientation through KVC onUIDevice(setValue(_:forKey: "orientation")) and calledUINavigationController.attemptRotationToDeviceOrientation(), deprecated in iOS 16attemptRotationToDeviceOrientation()fallback inunlock#available(iOS 16.0, *)checksfromOrientationTypeToInt(_:)is kept: it is still used to setsupportedOrientationson the bridge view controller.Deduplicated
The geometry update was identical in
lockandunlock, so it moved to a singlerequestGeometryUpdate(_:completion:)helper.Fixed along the way
completion(nil)ran unconditionally right after the request was made, so on failure the completion was invoked twice and the call resolved before it rejected.requestGeometryUpdate's error handler only runs when the request is rejected, so its result is now reported once, after the request. The plugin layer was missing areturnaftercall.reject, which had the same effect one level up.Verification
xcodebuild build -scheme CapacitorScreenOrientation -destination generic/platform=iOS: succeeds with no warnings. Before this change it emitted'attemptRotationToDeviceOrientation()' was deprecated in iOS 16.0.swiftlint lint --strict screen-orientation/ios: 0 violations.Android is untouched:
getLegacyDisplayRotation()looks similar but is still reachable, sinceminSdkVersionis 26 and the check guards API 30.RMET-5352