Open lostminds opened 1 month ago
While testing this further I discovered that the Godot Engine Editor has the same behavior of starting a separate process for additional .godot project files opened on macOS. However, in this case the second project file is opened as expected, so the editor must be getting the correct launch argument or accessing the sent file in some other way specific to the editor. So perhaps looking at how the editor handles secondary processes being launched as compared to other exported godot project could be useful.
This seems to be a macOS sandboxing issue. If you export the project with sandboxing off the secondary processes get the expected launch argument.
This seems to be a macOS sandboxing issue.
Sandboxed apps can't set command line arguments when starting a new instance. Current logic was implemented for the editor (which is not running in the sandbox and designed to run in multiple instances).
We probably should add an option to override this behavior in exported projects and instead of starting new instances pass filenames to a notification or user defined callback function.
Tested versions
Reproducible in 4.3bX and 4.3rc1
System information
macOS 14.5
Issue description
When launching an exported Godot project by opening a file in the OS (or dragging it onto the Dock/taskbar icon of the application) you can access this file path as the first launch argument in
OS.get_cmdline_args()
. There is currently no other way to get access to files passed from the OS as discussed in https://github.com/godotengine/godot-proposals/issues/10195 . If the process is already running when the file is sent from the OS, the current implementation is to start a new duplicate process and pass the file path as a launch argument for that.This works as expected on Windows, but not on macOS:
Steps to reproduce
var arguments:PackedStringArray = OS.get_cmdline_args()
And displays these in a label or prints them out.arguments
printed out containing the path to the file.arguments
being empty.If you want to be more advanced you can add something like this:
In the Additional Plist Content field of your macOS export, which should enable your exported application to open .txt files from macOS with it once it's installed.
Minimal reproduction project (MRP)
Since this is related to exported builds and exporting (at least successfully) to macOS requires inputting personal codesigning details I don't want to submit a MRP. But the steps to reproduce above should hopefully be minimal enough to be easy to reproduce.