Search code examples
macosdownloadlaunchmacos-mojave

Qt application for mac not being launched


I am working on an application written in Qt for macOS environment. In order to generate release build i have set up external server.

I am seeing this:

After generating build, if I download and install the application on Applications folder, when opening it, first I see the popup asking if I am sure to open app downloaded from Internet(Gatekeeper), so I click Open and then app dies.

App works fine if I open it from CommandLine in Terminal.

Checking the attributes of app file I can see that it has com.apple.quarantine. If remove it manually, using xattr -dr com.apple.quarantine application opens without any problem

Any ideas about why it is not launched ?? Thanks is advance


Solution

  • I had the same problem with my software and raised a developer incident which allowed to find the root cause:

    When launched the first time with the quarantine attribute, Gatekeeper will pass an additional command-line argument. From what I could observe, it is of the form:

    -psn_0_<some sequence of numbers>
    

    e.g.

    -psn_0_2445909
    

    Qt's QCommandLineParser rejects unknown arguments and calls exit(1); in that case.

    Thus it is necessary to filter argc / argv and remove that bogus argument before passing them to Q{Core,Gui,}Application.