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. Using Apples Information Property List Files (Info.plist) in Python on MacOS
Forum Updated to NodeBB v4.3 + New Features

Using Apples Information Property List Files (Info.plist) in Python on MacOS

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 3.0k 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.
  • WolleKetteW Offline
    WolleKetteW Offline
    WolleKette
    wrote on last edited by
    #1

    Hi at all,

    I am in the process of developing an application in python under macos that should use bluetooth. But already when I try to use the QBluetoothDeviceDiscoveryAgent I get an error message regarding an entry in the Info.plist.

    I read that an NSBluetoothAlwaysUsageDescription entry would be required in this file. And I also saw that on apple systems, this file is normally managed by xcode and will be included in the compiled package. But my program is written in python and there is no compiled package and I don't use xcode.

    Please, can someone give me a tip on how to do this?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerReisende
      wrote on last edited by
      #2

      The plist file is just a text file filled with the necessary data and put into the application bundle.
      So basically you could use a template/create one yourself with the keys and just copy it to the final bundle. On c++ qt with CMake you can create the plist file during build however I have no clue how to do that with python as I don't use it.
      What might also interfere with your Bluetooth use is the lack of an proper entitlement for your app. The Bluetooth usage description might be enough but if your app crashes on start you might be missing the Bluetooth entitlement. If you don't have Xcode available it might get tedious.

      1 Reply Last reply
      0
      • WolleKetteW Offline
        WolleKetteW Offline
        WolleKette
        wrote on last edited by
        #3

        I don't understand it anyway. For example, when I use bleak, a Python library for Bluetooth Low Energy, and run a scan there, I am asked if the application (the terminal in that case) is allowed to use Bluetooth.
        Then the terminal app as the caller is entered as Allowed in the settings under Security & Privacy / Bluetooth. And then it works. But this setting doesn't seem to apply to Python Qt and its QBluetoothDeviceDiscoveryAgent.

        But since bleak uses asyncio and that is problematic under Qt, I thought it would be easier to use Qt's Bluetooth modules.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerReisende
          wrote on last edited by
          #4

          I just ran the c++ BT scanner example without problems on my M1 Mac.
          Here is the Info.plist that is in the compiled file. Maybe it will work for you as well:

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
          <plist version="1.0">
          <dict>
                  <key>CFBundleExecutable</key>
                  <string>btscanner</string>
                  <key>CFBundleIconFile</key>
                  <string></string>
                  <key>CFBundleIdentifier</key>
                  <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
                  <key>CFBundlePackageType</key>
                  <string>APPL</string>
                  <key>CFBundleSignature</key>
                  <string>????</string>
                  <key>LSMinimumSystemVersion</key>
                  <string></string>
                  <key>NSPrincipalClass</key>
                  <string>NSApplication</string>
                  <key>NSBluetoothAlwaysUsageDescription</key>
                  <string>Qt BT Example wants to access your Bluetooth adapter</string>
                  <key>NSSupportsAutomaticGraphicsSwitching</key>
                  <true/>
          </dict>
          </plist>
          

          Obviously some entries are not entirely valid but I don't get any problems running locally.

          1 Reply Last reply
          0
          • WolleKetteW Offline
            WolleKetteW Offline
            WolleKette
            wrote on last edited by
            #5

            After several hours of searching the Internet, I have come to the conclusion that I am not on the right way.

            As I wrote above, the first time I use Bluetooth using the bleak modul, I am asked if I want to allow access. When using the QBluetoothDeviceDiscoveryAgent there is no request.

            While searching the internet, I found a post where someone had similar problems accessing the video camera. It said, that the manufacturer of the module is responsible for announcing it to the operating system before accessing corresponding components (video, bluetooth). And then the os dialog would appear asking the user for approval. Bleak apparently does that. Of course, I don't know if all this is correct, but it sounds right at first.

            The way via an info.plist apparently only works if you create an app. This would also be possible with python, but not in the development phase.I even found a description of how to create a suitably legitimized python interpreter app, which then launches the script. But that sounded pretty complicated.

            I can't believe that should be so complicated. After all, Qt offers the QBluetoothDeviceDiscoveryAgent module explicitly for Python.

            B 1 Reply Last reply
            0
            • WolleKetteW WolleKette

              After several hours of searching the Internet, I have come to the conclusion that I am not on the right way.

              As I wrote above, the first time I use Bluetooth using the bleak modul, I am asked if I want to allow access. When using the QBluetoothDeviceDiscoveryAgent there is no request.

              While searching the internet, I found a post where someone had similar problems accessing the video camera. It said, that the manufacturer of the module is responsible for announcing it to the operating system before accessing corresponding components (video, bluetooth). And then the os dialog would appear asking the user for approval. Bleak apparently does that. Of course, I don't know if all this is correct, but it sounds right at first.

              The way via an info.plist apparently only works if you create an app. This would also be possible with python, but not in the development phase.I even found a description of how to create a suitably legitimized python interpreter app, which then launches the script. But that sounded pretty complicated.

              I can't believe that should be so complicated. After all, Qt offers the QBluetoothDeviceDiscoveryAgent module explicitly for Python.

              B Offline
              B Offline
              BijanT
              wrote on last edited by
              #6

              @WolleKette
              Hi, did you ever find a solution to this? I'm running into the same issue.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Rida Shamasneh
                wrote on last edited by
                #7

                I have the same exact issue right now.
                PySide6 devs are blaming Cpython for this and they suggested re-building Cpython for scratch with cusotm info.plist. This looks tedious to me.
                https://bugreports.qt.io/browse/PYSIDE-2474

                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