Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Deploying on MacOS with QtIFW
QtWS25 Last Chance

Deploying on MacOS with QtIFW

Scheduled Pinned Locked Moved Solved Installation and Deployment
2 Posts 1 Posters 1.0k 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.
  • J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #1

    Hello everyone.

    I find myself in the situation that I want to deploy my code for Win, Linux and Mac. I would like to use the QtInstallerframework for this, since it became public use and QT itself uses it to deploy itself. But i'm a bit of a loss here.

    What is working properly:

    • I think I got the App-Bundle set up correctly
    • the Installer.app seems to create all neccessary files correctly too
    • I managed to create all shortcuts with Windows as OS

    The problem comes with the desktop short cut and /or finder/launchpad entry for macOS.

    The Docu shows only how to do it for Windows and online I've found mostly windows references as well as some linux tips- mostly from this forum :-)

    If I understand this correctly I'll have to modify only the installerscript for this
    Here is what I have:

    function Component()
    {
         if (systemInfo.productType === "windows") { 
            var programFiles = installer.environmentVariable("ProgramFiles");
            if (programFiles != "")
                 installer.setValue("TargetDir", programFiles + "/companyName/AppName");
        }
        if (systemInfo.productType === "mac") {
           var programFiles = installer.environmentVariable("TargetDir");
            if (programFiles != "")
                 installer.setValue("TargetDir", programFiles + "/companyName/AppName");
        }
    
    }
    
    Component.prototype.isDefault = function()
    {
        // select the component by default
        return true;
    }
    
    Component.prototype.createOperations = function()
    {
        try {
            // call the base create operations function
            component.createOperations();
        } catch (e) {
            console.log(e);
        }
    	
        if (systemInfo.productType === "windows") { 
           component.addOperation("CreateShortcut", "@TargetDir@/AppName.exe", "@StartMenuDir@/AppName.lnk", "workingDirectory=@TargetDir@");
    	component.addOperation("CreateShortcut", "@TargetDir@/AppName.exe", "@HomeDir@/Desktop/uConfig.lnk");
        }
        if (systemInfo.productType === "mac") {
            component.addOperation("CreateShortcut", "@TargetDir@/companyName/AppName/AppName.app", "@HomeDir@/Desktop/AppName");
        }
    }
    

    Obviously this does not result in a Dekstop - Link/Alias and I wouldn't know how to add an entry to the launchpad too. Hopefully someone can help me out here.

    Is that even possible with QtIFW? Because I had to create a desktop shortcut under mac manually after installing QtCreator.


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    1 Reply Last reply
    0
    • J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      So, I managed to answer my own question. Took me longer than I'll like to admit, but I'll share my workaround here, in case someone else has this problem:

      If you use apples osascript one can use a shell command to create a desktop alias.

      With that in mind I created a bash skript makeAlias.sh:

      #!/bin/bash
      
      osascript <<END_SCRIPT
      tell application "Finder" to make alias file to file (posix file "$1") at desktop
      END_SCRIPT
      

      That gets added to the app-bundle with the following code in the *.pro-file

      macx{
         App_Data.files = /path/to/script/makeAlias.sh
         App_Data.path= Contents/MacOS/data
         QMAKE_Bundle_Data += App_Data
      }
      

      the installscript.qs of the InstallerFramework, gets the following addition to execute the script:

      var argList = ["@TargetDir@/myApp.app/Contents/MacOS/data/makeAlias.sh", "@TargetDir@/myApp.app"];
      installer.execute("sh",argList);
      

      and done.
      In the end, quite easy ....


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      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