How to find the file (url) that was double-clicked to open my Cocoa Application?
How to find the file (url) that was double-clicked to open my Cocoa Application?
- Subject: How to find the file (url) that was double-clicked to open my Cocoa Application?
- From: Motti Shneor <email@hidden>
- Date: Wed, 30 Mar 2016 08:47:55 +0300
Hi Everyone. My issue is tied to a very specific scenario, but still a Cocoa question.
I write a custom Installer Plugin (code bundle), used to customize our installations (done via Mac Installer). The plugin bundle is loaded at some arbitrary time by the Installer App. It needs access to the actual package file on disk.
The Installer application logs (in /var/log/install.log) its actions and near to the start, it emits the following line:
Mar 30 07:47:54 CyberMotti Installer[19943]: Opened from: /Users/motti/Documents/Projects/MyTestLogDistribution/build/MyTestLogDistribution.pkg
Which contains exactly the info I need. Furthermore - at a much later stage of the installation, when the Installer runs some install-scripts I wrote, the Installer supplies this information also in the first argument sent to the scripts.
But my custom Plugin (Cocoa bundle with simple UI) doesn’t receive such information.
The path/URL to this file is not in the command-line arguments of the Installer App
30/03/2016 08:30:29.025 Installer[20208]: Command line arguments: (
"/System/Library/CoreServices/Installer.app/Contents/MacOS/Installer"
)
It is also Not in the environment of the Installer App:
30/03/2016 08:30:29.025 Installer[20208]: Process Environment: {
"Apple_PubSub_Socket_Render" = "/private/tmp/com.apple.launchd.y5SHsAh0Ek/Render";
HOME = "/Users/motti";
LOGNAME = motti;
PATH = "/usr/bin:/bin:/usr/sbin:/sbin";
SHELL = "/bin/bash";
"SSH_AUTH_SOCK" = "/private/tmp/com.apple.launchd.JZKmuCTDKg/Listeners";
TMPDIR = "/var/folders/r3/l6xqyz7d7nb2vpjv45hyyqkw0000gn/T/";
USER = motti;
"XPC_FLAGS" = 0x0;
"XPC_SERVICE_NAME" = "com.apple.installer.992";
"__CF_USER_TEXT_ENCODING" = "0x1F5:0x0:0x0";
}
I thought maybe the Installer is a Document-base app, and tried to look in the [NSDocumentController sharedController], but it is empty as well.
30/03/2016 08:30:29.025 Installer[20208]: Doc URLs:(
)
Obviously “Installer” isn’t Document based…
But still, If a package file was double-clicked to launch the Installer App, and it received an “Open File” event, is there a way to get to the file later on, without actually catching this event?
I already posted a question in the installer-dev list, but this is a general Cocoa question, so Any help will be greatly appreciated.
Motti Shneor
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden