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. Get app dir of application on Mac OS sierra

Get app dir of application on Mac OS sierra

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 3.5k 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.
  • cfdevC Offline
    cfdevC Offline
    cfdev
    wrote on last edited by
    #1

    Hi there,
    I have trouble with the QApplication::applicationDirPath() and QDir::currentPath() functions.

    On some computers this function return strange path:

    /private/var/folders/z0/lp84cp8d4831k8519j46qyt00000gn/T/AppTranslocation/D2CXXC75-CXX3-4689-8XXA-CCD4641072XX/d/mcercle.app/Contents/MacOS
    

    The correct path is

    /users/theuser/documents/mcercle...
    

    Why Qt can't find where is the application ?
    I found this http://doc.qt.io/qt-5/osx-issues.html#macos-native-api-access but on this page "QCoreApplication::applicationDirPath() can be used to determine the path of the binary within the bundle."

    thanks!

    1 Reply Last reply
    0
    • Chris HennesC Offline
      Chris HennesC Offline
      Chris Hennes
      wrote on last edited by
      #2

      This is part of a change to the way Gatekeeper works on Sierra - apps that aren't signed are moved to a randomized location before execution. So the path returned really is where your executable is, at the moment it is running. It's called "App Translocation."

      Chris Hennes, Pioneer Library System

      cfdevC 1 Reply Last reply
      3
      • Chris HennesC Chris Hennes

        This is part of a change to the way Gatekeeper works on Sierra - apps that aren't signed are moved to a randomized location before execution. So the path returned really is where your executable is, at the moment it is running. It's called "App Translocation."

        cfdevC Offline
        cfdevC Offline
        cfdev
        wrote on last edited by
        #3

        @Chris-Hennes Ok thanks for this information!
        But is there a solution to get some files where is really my application ...whitout QApplication::applicationDirPath() ? :(

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rondog
          wrote on last edited by
          #4

          Based on what I have read the 'Translocation' (lol) is only done if you are running an app from an archive like a DMG file. The purpose of this is to prevent a signed app from loading unsigned executables that are distributed along with the app. The relative path option would not be usable to give you the true location of the app which prevents this kind of attack.

          So, it is doubtful you will be able to find a work around to this.

          I expect that the relative path still works within the app container (folder). If you need to include some data or other files with your app why not put them inside the app (not alongside)?

          cfdevC 1 Reply Last reply
          0
          • R Rondog

            Based on what I have read the 'Translocation' (lol) is only done if you are running an app from an archive like a DMG file. The purpose of this is to prevent a signed app from loading unsigned executables that are distributed along with the app. The relative path option would not be usable to give you the true location of the app which prevents this kind of attack.

            So, it is doubtful you will be able to find a work around to this.

            I expect that the relative path still works within the app container (folder). If you need to include some data or other files with your app why not put them inside the app (not alongside)?

            cfdevC Offline
            cfdevC Offline
            cfdev
            wrote on last edited by
            #5

            @Rondog ...If you need to include some data or other files with your app why not put them inside the app (not alongside)?...

            you mean put the files into in the app bundle ?

            jsulmJ 1 Reply Last reply
            0
            • cfdevC cfdev

              @Rondog ...If you need to include some data or other files with your app why not put them inside the app (not alongside)?...

              you mean put the files into in the app bundle ?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @cfdev You can put them into your executable. See http://doc.qt.io/qt-5/resources.html

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              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