feat!: migrate to Capacitor v8#407
Conversation
- Replace deprecated `UIApplication.shared.statusBarOrientation` with `UIWindowScene` logic. - Replace deprecated `jpegPhotoDataRepresentation` with `fileDataRepresentation`. - Fix logic bug in `UIImage.fixedOrientation` where transform results were unused. - Fix various linter issues.
|
reopen |
|
I close it for now... until this will be solved ionic-team/capacitor-swift-pm#33 |
|
Reopen. latest changes made:
|
|
Hi, @fabiomartino @ryaa is it possible to merge this update to Capacitor v8? |
I will try to get to this the next week. |
ryaa
left a comment
There was a problem hiding this comment.
Blocker: example-app not upgraded
The example-app still depends on Capacitor 7 across package.json, Podfile (platform :ios, '14.0'), and variables.gradle (compileSdkVersion = 35). Since the plugin's peerDependencies now require @capacitor/core >=8.0.2 and the podspec requires iOS 15, the example-app can't install or build against the plugin. I believe that we need to upgrade the example-app deps, bump the Podfile platform to 15.0, bump variables.gradle SDK versions to 36, and run cap sync.
Minor suggestions (non-blocking):
- The #available(iOS 13.0, *) checks in getInterfaceOrientation() and updateVideoOrientation() are always true now that the deployment target is iOS 15 — the statusBarOrientation fallback is dead code. Consider removing.
- lintOptions in android/build.gradle is deprecated in AGP 8.x — could be renamed to lint since you already touched that block.
Changes: - update the example-app @capacitor/* dependencies to Capacitor 8-compatible versions - align the example-app iOS configuration with the plugin’s new minimum iOS requirement - align the example-app Android configuration with the Capacitor 8 migration requirements - refresh generated/native example-app project state as needed after the upgrade - fix the Android example-app build issue encountered during validation by updating the Android variables/config - ensure the repository example-app can be used for end-to-end validation of the Capacitor 8 plugin migration
Changes: - remove unnecessary `#available(iOS 13.0, *)` checks introduced during the Capacitor 8 migration - remove obsolete `UIApplication.shared.statusBarOrientation` fallback branches - use `connectedScenes` / `UIWindowScene` orientation lookup unconditionally for the iOS 15+ target - keep behavior unchanged while simplifying the iOS orientation helpers
Changes:
- replace deprecated `lintOptions {}` with `lint {}` in the plugin Android Gradle file
|
@fabiomartino I went ahead and resolved all of my review findings on this PR. This included:
From my side, the review items I raised have now been addressed. Can you please review and confirm that this PR can be merged? (we can also plan to release a new build with the capacitor 8 support after that). |
|
Hi @ryaa, sounds good! Just a quick note: we could further update some dependencies (like Capacitor to the current v8.2.0), but it’s not strictly necessary for this PR and can be handled later. Currently, I don’t have the time to make further changes myself, so feel free to proceed with the merge if the current state looks good to you. If any minor tweaks are needed, you’re welcome to push them or I can look into them after the second week of April. |
|
@fabiomartino I have merged the changes into master. The next step will be to publish a new build with Capacitor 8 support. I’ll try to do that as soon as possible, unless there are any objections. |
|
Thank you @ryaa @fabiomartino Your support is appreciated. |
|
v8.0.0 has now been released with Capacitor 8 support. |
This PR updates the plugin to support Capacitor v8. The migration follows the official Capacitor v8 plugin upgrade guide.
This update addresses build issues on Android and specifically fixes compilation errors on iOS introduced by the stricter Swift Package Manager (SPM) integration in Capacitor v8.
Key Changes
📱 iOS (Swift & SPM)
The transition to Capacitor v8 and its default usage of Swift Package Manager required several adjustments in
CameraPreviewPlugin.swiftandCameraController.swift:rejectvsresolve):call.reject()is not reliably exposed or callable in the same way as CocoaPods.call.reject("message")with a state-based resolution pattern:call.resolve(["success": false, "error": "message"]). This ensures the plugin compiles and behaves consistently across toolchains.getInt,getString) are retrieved. Capacitor v8 accessors now enforce strict non-optional returns in certain contexts.call.options["key"]or provided explicit default values where appropriate to prevent runtime crashes and build errors.UIApplication.shared.statusBarOrientation(iOS 13+) with modernUIWindowScenelogic to correctly determine interface orientation.📦 Dependencies (NPM)
@capacitor/core,@capacitor/android, and@capacitor/iosto^8.0.0.package.jsoncontains specificoverridesfor ESLint versions. To respect your current configuration and avoid altering the repository's architecture or linting rules, I utilizednpm install --forceto resolve the peer dependency graph. You may want to review theoverridessection in a future maintenance update to align it with the newer TypeScript/ESLint ecosystem, but for now, I have left it as is to minimize friction.This PR has been tested locally on both Android and iOS.
However, since this plugin interacts with system-level settings and behavior can vary
between devices and OS versions, it is strongly recommended that the original maintainer
also tests these changes in their own environment before approving and releasing.
No breaking changes are introduced beyond the already required Capacitor 8 migration.