capacitor: bug: cordova ScreenOrientation plugin is not installed error after Xcode upgraded to 14.3 and iOS to 16.4
Bug Report
This problem might be related to https://github.com/ionic-team/capacitor/issues/6457 since it also appeared after XCode has been upgraded to 14.3. UPDATE: The iOS version has also been upgraded to 16.4. Please note that the app with cordova-plugin-screen-orientation plugin seems to work fine on iOS 15.x therefore this could be related to iOS version upgrade.
Capacitor Version
Latest Dependencies:
@capacitor/cli: 4.7.3
@capacitor/core: 4.7.3
@capacitor/android: 4.7.3
@capacitor/ios: 4.7.3
Installed Dependencies:
@capacitor/cli: 4.4.0
@capacitor/core: 4.4.0
@capacitor/android: 4.4.0
@capacitor/ios: 4.4.0
Platform(s)
MacOS Ventura 13.3 with XCode 14.3
Current Behavior
The cordova-plugin-screen-orientation plugin stopped working and XCode shows the below error in the console:
⚡️ [warn] - Native: tried calling ScreenOrientation.lock, but the ScreenOrientation plugin is not installed.
⚡️ [warn] - Install the ScreenOrientation plugin: 'ionic cordova plugin add cordova-plugin-screen-orientation'
⚡️ [error] - Rollbar: Error: Uncaught (in promise): plugin_not_installed
⚡️ [error] - ERROR Error: Uncaught (in promise): plugin_not_installed
Expected Behavior
No error and the cordova screen orientation plugin can be found/installed
Code Reproduction
The problem started to appear for iOS native project using cordova-plugin-screen-orientation after XCode has been upgraded to the latest version 14.3
Other Technical Details
npm --version
output:
9.6.1
node --version
output:
v18.12.0
pod --version
output (iOS issues only):
1.12.0
Additional Context
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 16 (6 by maintainers)
this is a bug in the plugin https://github.com/apache/cordova-plugin-screen-orientation/issues/114
more like a conflict because iOS 16.4 started supporting the
screen.orientation
API, which the plugin overwritesYes. Since the Cordova plugin is broken right now for WebKit 16.4+, any usages of it in those cases will fail. To fix them, you’d instead be using the Capacitor plugin.
I imagine you could still bundle the Cordova plugin in the app and could use it in WebKit < 16.4 conditionally, but you couldn’t use it with 16.4+.
Unless there’s a good use case for trying to use both, I think it’d be notably simpler to migrate the whole project to use the Capacitor plugin.
We resolved it by migrating to the recently-released, official/first-party Capacitor Screen Orientation plugin. It’s a migration we wanted to perform anyway.
Plugin seems to work great. It also implements the Screen Orientation Web API on Web, so it can work in browsers. However, you’d need to be careful of browsers that don’t implement the Web API (for example, Safari < 16.4).
That will be fixed in the release scheduled for this week. It’s already fixed in the version 5 beta of the plugin.
Thanks a lot for your help, @KevinKelchen 🙏🏼 And thanks also for the explanation, @jcesarmobile 🙏🏼 So I know what I have to do this night 🧑🏼💻
I was struggling to create a sample project to reproduce the problem and the new project with nothing but cordova screen orientation plugin works just fine on the latest iOS 16.4 however, the problem is 100% reproducible in my real app. As mentioned in this bug the problem is intermittent, which explains the behavior that I observed.
Can you send me a sample project to look at?