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.
  • C Offline
    C Offline
    cfdev
    wrote on 2 Mar 2017, 14:55 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
    • C Offline
      C Offline
      Chris Hennes
      wrote on 2 Mar 2017, 15:45 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

      C 1 Reply Last reply 3 Mar 2017, 08:20
      3
      • C Chris Hennes
        2 Mar 2017, 15:45

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

        C Offline
        C Offline
        cfdev
        wrote on 3 Mar 2017, 08:20 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 3 Mar 2017, 13:26 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)?

          C 1 Reply Last reply 4 Mar 2017, 15:10
          0
          • R Rondog
            3 Mar 2017, 13:26

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

            C Offline
            C Offline
            cfdev
            wrote on 4 Mar 2017, 15:10 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 ?

            J 1 Reply Last reply 6 Mar 2017, 05:47
            0
            • C cfdev
              4 Mar 2017, 15:10

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

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 6 Mar 2017, 05:47 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

              4/6

              3 Mar 2017, 13:26

              • Login

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