Issue with CameraPermission requests on iOS with Qt 6.6[.1]
-
Greetings,
We have stumbled on an issue with the camera permission handling on iOS when upgrading our cross-platform application QField to Qt 6.6[.1].
At the moment, we are requesting the permission via a QML CameraPermission object:
if (cameraPermission.status !== Qt.PermissionStatus.Granted) { cameraPermission.request() }
While everything works as expected on Android, we never see a request pop up on iOS and the following is printed in the console:
Could not request QCameraPermission. Please make sure you have included the required usage description in your Info.plist
The warning comes from this bit of code (https://github.com/qt/qtbase/blob/4bce81b03b27916a43933f7d3faa804027df52b8/src/corelib/platform/darwin/qdarwinpermissionplugin.mm#L78-L80). However, our Info.plist already contains the relevant NSCameraUsageDescription and NSMicrophoneUsageDescription keys here (https://github.com/opengisch/Qfield/blob/master/platform/ios/Info.plist.in#L68-L72).
We are building the app statically using CMake against the official compiled Qt libraries installed via aqt.
I’m wondering whether we are missing something in the CMakeLists.txt file that would prevent the relevant permission plugin (QDarwinCameraPermissionPlugin) from functioning properly. At the moment, we have tried this, which is unfortunately not working:
if(IOS) target_link_libraries( ${exe_TARGET} PUBLIC ${QT_PKG}::QDarwinCameraPermissionPlugin ${QT_PKG}::QDarwinMicrophonePermissionPlugin ${QT_PKG}::QDarwinLocationPermissionPlugin) qt_import_plugins( ${exe_TARGET} INCLUDE ${QT_PKG}::QDarwinCameraPermissionPlugin ${QT_PKG}::QDarwinMicrophonePermissionPlugin ${QT_PKG}::QDarwinLocationPermissionPlugin) endif()
I’ve done some digging prior to drafting this post and could not find the solution. Crossing fingers someone in this forum will have the answer so we and others can successfully migrate to Qt 6.6.
-
@tobtoht It looks like they created a workaround: See pull request
I am facing the same problem after updating from Qt 6.5.1 to 6.7.0, should I find the answer I will post it here.
The declarative camera example from Qt works in Qt 6.7.0, but I have not found the difference between the example and my app yet.
-
@tobtoht It appears to be a CMake issue (likely on Qt side).
If your CMake project has a single call to
find_package(Qt6 ... )
it will work, but if you have more than one it will cause the problem we had.I think this is a bug, without multiple calls you can't have more than one Qt app in a project, at least I get problems if I do not call
find_package( Qt6 ...)
in theCMakeLists.txt
in which theqt_add_executable
entry is.I will try to dig deeper, if I can't find a solution I will open a bug.
-
@tobtoht The CMake code of Qt itself is too much for me. But I think I have a valid workaround.
This is my project structure, this does not work:
src/CMakeLists.txt find_package(Qt6 ... ) add_subdirectory(App1 ) add_subdirectory(App2 ) src/App1/CMakeLists.txt find_package(Qt6 ... ) src/App2/CMakeLists.txt find_package(Qt6 ... )
This is the structure Qt says we should use, this seems to cause other issues for me:
src/CMakeLists.txt find_package(Qt6 ... ) add_subdirectory(App1) add_subdirectory(App2) src/App1/CMakeLists.txt # dont find_package(Qt6 ... ) src/App2/CMakeLists.txt # dont find_package(Qt6 ... )
This is what actually works:
src/CMakeLists.txt add_subdirectory(App1) add_subdirectory(App2) src/App1/CMakeLists.txt find_package(Qt6 ... ) src/App2/CMakeLists.txt find_package(Qt6 ... )
-
I caused the problem myself: Check for details
Not sure if anything I learned applies to you.
-