Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qt.permissions: Could not find permission plugin for QLocationPermission.
Forum Updated to NodeBB v4.3 + New Features

qt.permissions: Could not find permission plugin for QLocationPermission.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 606 Views
  • 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.
  • K Offline
    K Offline
    KejPi
    wrote on last edited by
    #1

    Hi there,

    I am developing application on MacOS with Qt 6.6.3 and I want to ask for location permission, however if I do so, I get this message in terminal output:

    qt.permissions: Could not find permission plugin for QLocationPermission. Please make sure you have included the required usage description in your Info.plist
    

    This is my code:

    void TIIDialog::startLocationUpdate()
    {
        // ask for permission
    #if QT_CONFIG(permissions)
        QLocationPermission locationsPermission;
        locationsPermission.setAccuracy(QLocationPermission::Precise);
        locationsPermission.setAvailability(QLocationPermission::Always);
        switch (qApp->checkPermission(locationsPermission)) {
        case Qt::PermissionStatus::Undetermined:
            qApp->requestPermission(locationsPermission, this, []() { qDebug() << "permission request completed"; } );
            qDebug() << "Undetermined";
            return;
        case Qt::PermissionStatus::Denied:
            qDebug() << "Denied";
            return;
        case Qt::PermissionStatus::Granted:
            qDebug() << "Granted";
            break; // Proceed
        }
    #endif
        // start location update
    }
    

    This is may Info.plist in the app bundle:

    $ cat AbracaDABra.app/Contents/Info.plist 
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleExecutable</key>
        <string>AbracaDABra</string>
        <key>CFBundleGetInfoString</key>
        <string></string>
        <key>CFBundleIconFile</key>
        <string>appIcon.icns</string>
        <key>CFBundleIdentifier</key>
        <string></string>
        <key>CFBundleShortVersionString</key>
        <string></string>
        <key>CFBundleName</key>
        <string></string>
        <key>CFBundleShortVersionString</key>
        <string></string>
        <key>CFBundleVersion</key>
        <string>_</string>
        <key>CSResourcesFileMapped</key>
        <true/>
        <key>NSHumanReadableCopyright</key>
        <string>© 2019-2024 Petr Kopecký - MIT License</string>
        <key>NSPrincipalClass</key>
        <string>NSApplication</string>
        <key>NSHighResolutionCapable</key>
        <string>True</string>
        <key>LSMinimumSystemVersion</key>
        <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
        <key>CFBundleAllowMixedLocalizations</key>
        <true/>
        <key>NSLocationUsageDescription</key>
        <string>AbracaDABra would like to access your location for trasmitters visualisation.</string>
    </dict>
    </plist>
    

    And I have this in my CMakeLists.txt:

    # Set a custom plist file for the app bundle
    if(APPLE AND APPLE_APP_BUNDLE)
        set_target_properties(${TARGET} PROPERTIES
            MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist.in
            MACOSX_BUNDLE_BUNDLE_VERSION       "${PROJECT_VERSION}_${PROJECT_GIT_REV}"
            MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}"
        )
        if (NOT CMAKE_GENERATOR STREQUAL "Xcode")
            # Need to sign application for location permissions to work
            add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND codesign -s - ${TARGET}.app)
        endif()
    endif(APPLE AND APPLE_APP_BUNDLE)
    

    What am I doing wrong? Thank you!

    K 1 Reply Last reply
    0
    • K KejPi

      Hi there,

      I am developing application on MacOS with Qt 6.6.3 and I want to ask for location permission, however if I do so, I get this message in terminal output:

      qt.permissions: Could not find permission plugin for QLocationPermission. Please make sure you have included the required usage description in your Info.plist
      

      This is my code:

      void TIIDialog::startLocationUpdate()
      {
          // ask for permission
      #if QT_CONFIG(permissions)
          QLocationPermission locationsPermission;
          locationsPermission.setAccuracy(QLocationPermission::Precise);
          locationsPermission.setAvailability(QLocationPermission::Always);
          switch (qApp->checkPermission(locationsPermission)) {
          case Qt::PermissionStatus::Undetermined:
              qApp->requestPermission(locationsPermission, this, []() { qDebug() << "permission request completed"; } );
              qDebug() << "Undetermined";
              return;
          case Qt::PermissionStatus::Denied:
              qDebug() << "Denied";
              return;
          case Qt::PermissionStatus::Granted:
              qDebug() << "Granted";
              break; // Proceed
          }
      #endif
          // start location update
      }
      

      This is may Info.plist in the app bundle:

      $ cat AbracaDABra.app/Contents/Info.plist 
      
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
      <plist version="1.0">
      <dict>
          <key>CFBundleInfoDictionaryVersion</key>
          <string>6.0</string>
          <key>CFBundlePackageType</key>
          <string>APPL</string>
          <key>CFBundleDevelopmentRegion</key>
          <string>English</string>
          <key>CFBundleExecutable</key>
          <string>AbracaDABra</string>
          <key>CFBundleGetInfoString</key>
          <string></string>
          <key>CFBundleIconFile</key>
          <string>appIcon.icns</string>
          <key>CFBundleIdentifier</key>
          <string></string>
          <key>CFBundleShortVersionString</key>
          <string></string>
          <key>CFBundleName</key>
          <string></string>
          <key>CFBundleShortVersionString</key>
          <string></string>
          <key>CFBundleVersion</key>
          <string>_</string>
          <key>CSResourcesFileMapped</key>
          <true/>
          <key>NSHumanReadableCopyright</key>
          <string>© 2019-2024 Petr Kopecký - MIT License</string>
          <key>NSPrincipalClass</key>
          <string>NSApplication</string>
          <key>NSHighResolutionCapable</key>
          <string>True</string>
          <key>LSMinimumSystemVersion</key>
          <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
          <key>CFBundleAllowMixedLocalizations</key>
          <true/>
          <key>NSLocationUsageDescription</key>
          <string>AbracaDABra would like to access your location for trasmitters visualisation.</string>
      </dict>
      </plist>
      

      And I have this in my CMakeLists.txt:

      # Set a custom plist file for the app bundle
      if(APPLE AND APPLE_APP_BUNDLE)
          set_target_properties(${TARGET} PROPERTIES
              MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist.in
              MACOSX_BUNDLE_BUNDLE_VERSION       "${PROJECT_VERSION}_${PROJECT_GIT_REV}"
              MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}"
          )
          if (NOT CMAKE_GENERATOR STREQUAL "Xcode")
              # Need to sign application for location permissions to work
              add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND codesign -s - ${TARGET}.app)
          endif()
      endif(APPLE AND APPLE_APP_BUNDLE)
      

      What am I doing wrong? Thank you!

      K Offline
      K Offline
      KejPi
      wrote on last edited by
      #2

      OK, I will answer myself, I hope it helps others in future. In order to make the permissions work you need to have this in CMakeLists.txt (I did not need it so far):

      ## This is required for localization permissions to work
      if(QT_VERSION_MAJOR EQUAL 6)
          qt_finalize_executable(${TARGET})
      endif()
      
      
      1 Reply Last reply
      1
      • K KejPi has marked this topic as solved on
      • T Offline
        T Offline
        thierry
        wrote on last edited by
        #3

        I still cannot make this work. I have even tried to build Qt 6.7.2 from sources to see and the weatherinfo example just exhibits this problem. Any help is very welcome.

        1 Reply Last reply
        0

        • Login

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