qt program deployed on mac. config file not writing when standalone app launched, works when run from within qt creator - macos

I have a program that I have developed for mac osx. When the program is run from within Qt creator, a log file and a config.cfg file are created in the myapp.app/Contents/MacOS folder, alongside the executable. This is the correct behaviour, the program needs these files.
When I deploy the app to run standalone (by linking the required libraries using macdeploymentqt tool) the app launches and runs correctly however the log and config.cfg file do not get written to the myapp.app/Contents/MacOS folder and so settings can't be read in.
Is there anyway to get around this? Has anyone encountered this before?
Mitch

osx will likely not allow you writing to your bundle location on installed apps, for security reasons and because it may conflict when multiple users are using your app.
To be cross platform, you could write instead to:
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
which resolves to
~/Library/Application Support/<APPNAME>
and
C:/Users/<USER>/AppData/Local/<APPNAME>
or equivalent on windows.

You're never supposed to write to the application bundle, whether on Mac or on Windows. Even on Windows, it will not work if your user isn't an administrator. This idea last made sense on Windows 95 - not even on Windows NT. Don't do it.

Related

how to run a self-contained asp.net core api in Mac Os

At first I have to apologize that I know it's a stupid question but since I don't have Mac computer so I can't test it as well, and I also failed to find document in Microsoft about the actions after publish, then I reach here to gather a confirmation from wise SO contributers.
I have an asp.net core project and I published it as self-contained application. When I choose the target OS as windows, then I will get an EXE file in the publish folder, then in a windows OS without .net runtime, I can still run the app by just double clicking the exe file.
Okay, then here's the question, when I choose the target OS as osx-x64, I can get a file like screenshot below. Then if I have a Mac computer, how can I run this File? The Mac wouldn't have .net runtime, and at first I think this app may also can be run by just double clicking the file. Am I right? Or it should be run within a command line like cd xxx first then ./filename?
Thank you very much in advance for your confirmation.

Windows 10 EV code signing no longer works on electron app

I have an electron app. Pretty basic app. It doesn't use ffmpeg for anything it does play an mp3 chime from time to time. I build my app with electron-forge using squirrel format. I then sign it using the SafeNet Authentication app. It's always worked flawlessly.
It's been a couple months since I last released a version. Only thing that has changed is some html ui updates within my electron app and of course lots of Windows 10 updates.
My app builds fine using electron-forge, it installs and runs without issue. I then sign it like usual from the command line and SafeNet confirms it was signed. Right clicking on the file shows it has been signed by my organization. However, once I execute the signed app I get this error: "The code execution cannot proceed because ffmpeg.dll was not found. Reinstalling the program may fix this problem."
Here is what I have tried so far:
Building/Signing on a different windows 10 machine.
Uninstall/Reinstall SafeNet.
Running signed .exe on a different Windows 10 instance
Building/Signing with a cmd session ran as administrator
I am at a loss, why is it screaming about ffmpeg.dll which my app doesn't depend on? Why only after the .exe has been signed do I get this error?
OS: Windows 10
Electron v7.3.2
Electron-Forge/cli v6.0.0-beta.47
SafeNet x64 v10.3
I feel really stupid. I was trying sign the wrong .exe file. Electron-forge creates two output directories when building an app, a directory called "make" and a directory with the name of your app. I should have been signing the .exe in the make folder. The .exe in the app name folder is a stand alone .exe that doesn't have any of the supported .dll files built into it.
After run the
npx #electron-forge/cli import and `npm run make`
Inside the project folder path it creates out folder. Inside out, there are two folders make and electron..........
Go to make then 64x and then you can find .exe
Use that one. It will work without any issue.

How to generate an installer package for Mac app?

How can I create a single installer package for an OS X binary as well as a few configuration and script files?
Final folders should look like this:
Any help would be appreciated. Thanks.
Installers are great if you want various things to be placed in different spots – app here, documentation there, support files over here, etc. They're also great for providing configurability of the installation experience (optional extras), or hand-holding for an unusual type of installation that the user might not otherwise understand, or extra work (configuration scripts, permissions modifications, authentication, compatibility checking, etc.) that need to run during the installation process. There is nothing wrong with installers, contrary to the answer from #d00dle, although there is also nothing wrong with distributing your app through the App Store, or as a dmg.
For setting up your own installers, I highly recommend a program called Packages (http://s.sudre.free.fr/Software/Packages/about.html). I am in no way connected to it, but I use it to build the installer for an app that I work on. It greatly smoothes the process of making a complex installer, and has an excellent GUI interface.
There's also macOS Installer Builder, which is a CLI you can use to create an installer wizard for your .pkg: https://github.com/KosalaHerath/macos-installer-builder
macOS does not normally use installers. Applications are packaged in app containers with the extension .app. This container is "executable" but you're also able to dig in and see what is inside. This is also the format distributed through App Store.
You can create .pkg or .dmg "installers" if necessary, however this is clearly not something apple aims to be standard. I would advise to use the .app pattern and any scripts needed should be self contained and executed on first run.
You can use .dmg to distribute your application outside of App Store (this is still fairly normal).
macOS also includes a terminal program called productbuild that builds a product archive for the macOS Installer or the Mac App Store. Enter man productbuild into the Terminal on a Mac for the manual page.

How do I package my appjs app?

I'm trying to release a package for my appjs app but there doesn't seem to be any easy way for end users to "just run" the application without a terminal.
Is there anyway to do this that is fool proof?
So I've found an easy way to do this, not necessarily the easiest way but it works.
OSx
I use this bash script to convert my folder to a .app folder (which is all OSx needs apparently)
Windows
and on Windows I use IsTools to create my in/un-staller and shortcuts.
Linux
I've not found an easy peasy way to do this on Linux yet but we don't have a customer base on Linux so it doesn't matter. I have however found this but it seems awefully convoluted. Shan't bother for now.
If you download the distributable for your platform from: http://appjs.org/#download. Then it includes a launch script -- app.exe for windows and app.sh for linux / mac os which launches everything without a console.
There is also an addition to appjs that installs appjs as a platform feature (rather than having the whole runtime in each application you distribute). Using this you can compile your application into a single file which you can then distribute to end users. This functionality is being actively developed and improved. http://appjs.delightfulsoftware.com/. see also screenshot tour for windows: http://appjs.delightfulsoftware.com/win.htm and for ubuntu linux: http://appjs.delightfulsoftware.com/ubuntu.htm.
/Simon

Mac app crashes from finder but runs inside Terminal

I tried searching, but did not find a specific post that could answer my question.
For my MacOS app, I have an external framework residing in /Library/Frameworks that I am linking to.
The app runs fine from Xcode. The app runs fine by itself on my dev system.
If I copy the app bundle over to another machine, and also copy over the external framework to /Library/Frameworks area (so it has a similar setup to my dev machine), the app crashes when it tries to perform the task that uses the external framework.
What's weird is that the app does not crash on the other machine if run from the terminal, or through gdb. It only crashes on the feature using the external framework when launched from the Finder. I made sure permissions etc are all open.
The crash is of BAD_ACCESS (SIGSEGV) type and the feature involves using the framework to write out a file.
Any thoughts about what could be causing the crash/how to go about debugging this?
Thanks
The most likely difference you're running into is working directories -- launching an application manually from the terminal will run it in whatever directory you happen to be in at the time, while launching it normally (e.g, by double-clicking it in the Finder) will start it up with a working directory of /. Make sure you aren't using any relative paths by mistake.

Resources