Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 2, 2012, 09:04 PM   #1
thricenightly
macrumors newbie
 
Join Date: Apr 2012
LaunchServices installation puzzlement

I've been programming for UNIX for 20 years or so, but I'm an absolute newbie at Mac programming. I find myself needing to write a cross platform application for Windows, Mac and Linux, and have it all complete except an installation issue with the Mac.

I have an application which needs to launch from a special protocol link in Safari. The cross platform environment I wrote my application in (Tcl/Tk) doesn't support LaunchServices so I have a little Apple Script to make the connection for me. It look like this:

on open location iwgLink
do shell script "open -a Injector --args \"" & iwgLink & "\""
end open location

where "Injector" is the main application which takes the link on its command line. I build this script into an application along with a suitable info.plist and it works. Good start.

The issue is installation. The little application wrapping the above script arrives contained a single archive file, which also carries the main application, its resources, config, and so on. Tcl/Tk works by making this archive executable, so the user downloads it, runs it, and it copies everything into place. Arriving on the Mac in that manner doesn't allow the OS to spot that it needs to be attached to the LaunchServices for the protocol, so the installer then runs the "lsregister" command to ensure the OS knows what's going on.

At this point things look OK. Looking at lsregister's dump I can see my little script application, and when I click on my special link in Safari a dialog pops up asking if I want to do this. If I select the "show application" option from that dialog Finder pops up showing me my script application, so I'm pretty confident that MacOS knows what it's supposed to do with the link.

Only when I click "open" in the dialog saying I want to run my little script, it fails. There's a flicker in the Dock where the icons move to make room for a new one, then they instantly move back again. The effect is what you'd expect if my script started then immediately exited. The script, in fact, is apparently not running. I put a "beep" in there so I'd know if it at least gets going, and it doesn't. I'm not sure how to debug this situation.

But there's a way to solve the problem. If I go to Finder and move the little script application to my USB stick, then move it straight back again, everything then works. Launch services starts my script, my script starts my application, and everything works.

So the question is simply: what extra step does Finder do when you drag and drop an application, that running a low level copy and lsregister doesn't?
thricenightly is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
installation of OS x Jellezilla MacBook Pro 3 Aug 28, 2013 10:43 AM
Installation of os x parthkanani MacBook 4 Aug 11, 2013 01:07 PM
Installation smokie1206 Wasteland 7 Apr 1, 2013 05:00 AM
Which way of installation is better ? rupam.db OS X 10.8 Mountain Lion 1 Jul 9, 2012 03:44 PM

Forum Jump

All times are GMT -5. The time now is 07:56 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC