I have already posted asking about this:
[quote='768005021, CynthiaSun, /thread/768005, /profile/CynthiaSun']
Codesigned and notarized app cannot directly write files inside the app bundle...
[/quote]
But there are still some doubts that have not been answered.
We use Qt to develop an application on the macOS platform, and we are attempting to perform code signing and notarization to ensure our the application is trusted by Apple.
However, there are a few things that seem weird regarding this statement:
"App bundles are read-only by design."
Let me provide more details.
Currently, when our application starts, it needs to create folder (e.g. Temp) in the root directory of the executable
For example: Myapp.app/Contents/MacOS/Myapp ---> Myapp.app/Contents/MacOS/Temp
The folder is designed for storing runtime logs or config files for our application. In the past, users may also modify the settings inside target folder if needed.
However, the strange thing is that after the application is codesigned and notarized.
When we double-click the application Myapp (a.k.a Myapp.app) in Finder, it could successfully launch and create the Temp folder inside the Myapp.app/Contents/MacOS folder.
However, when we navigate and attempt to run the main application executable in command line mode (as our application supports this command line execution)
$ cd Myapp.app/Contents/MacOS
$ ./Myapp -h
As our application will check if the root folder has write permission before starting (i.e., check if Myapp.app/Contents/MacOS is writable because we require to create Temp folder in the following steps)
It pop up the error that folder does not have write permission.
The aforementioned scenarios seems to conflict with this statement: "App bundles are read-only by design" (because when the application is launched directly by clicking in Finder, the Temp folder can be created successfully, but via the console command line, it cannot).
I would like to confirm again if writing files in the notarized application MacOS directory is not allowed?
If not, have any recommended approaches? (e.g., changing the folder to another directory). What causes the different results in these running scenarios?
We are not concerned about breaking the signature after application launched, as it seems that macOS will add it to system trust list after first time successfully launch. (Download the app from internet --> System: it is an app downloaded from the internet. Are you sure want to open it...? OK --> Although our application creates the Temp folder after first launch, when we click the application second time, it could directly open the app)
General
RSS for tagDemystify code signing and its importance in app development. Get help troubleshooting code signing issues and ensure your app is properly signed for distribution.