Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Issue with CameraPermission requests on iOS with Qt 6.6[.1]
Forum Updated to NodeBB v4.3 + New Features

Issue with CameraPermission requests on iOS with Qt 6.6[.1]

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 3 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nirvn
    wrote on last edited by nirvn
    #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()
    

    (https://github.com/opengisch/QField/pull/4802/files#diff-c465e5ba8795855c88200e0f31078db072ddf7ef6fddb2c0c0d7d630fbcb1506R129-R138)

    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.

    T 1 Reply Last reply
    0
    • N nirvn

      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()
      

      (https://github.com/opengisch/QField/pull/4802/files#diff-c465e5ba8795855c88200e0f31078db072ddf7ef6fddb2c0c0d7d630fbcb1506R129-R138)

      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.

      T Offline
      T Offline
      tobtoht
      wrote on last edited by
      #2

      @nirvn Were you able to find a solution? I'm having the exact same issue on macOS (Sonoma 14.2.1).

      M 3 Replies Last reply
      0
      • T tobtoht

        @nirvn Were you able to find a solution? I'm having the exact same issue on macOS (Sonoma 14.2.1).

        M Offline
        M Offline
        MS_36
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • T tobtoht

          @nirvn Were you able to find a solution? I'm having the exact same issue on macOS (Sonoma 14.2.1).

          M Offline
          M Offline
          MS_36
          wrote on last edited by
          #4

          @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 the CMakeLists.txt in which the qt_add_executable entry is.

          I will try to dig deeper, if I can't find a solution I will open a bug.

          1 Reply Last reply
          0
          • T tobtoht

            @nirvn Were you able to find a solution? I'm having the exact same issue on macOS (Sonoma 14.2.1).

            M Offline
            M Offline
            MS_36
            wrote on last edited by
            #5

            @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 ... )
            
            1 Reply Last reply
            0
            • M Offline
              M Offline
              MS_36
              wrote on last edited by
              #6

              I caused the problem myself: Check for details

              Not sure if anything I learned applies to you.

              1 Reply Last reply
              0
              • JoeCFDJ JoeCFD referenced this topic on

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved