问题
I would like my application to be automatically added to the dock after the package (DMG) is installed?
Does anyone know how to do this?
回答1:
There's a couple ways to do this, Andrew, and a lot of this depends on how you're doing your application installing.
If you are using PackageMaker to install your app, you can run a "postflight" script which adds your app's icon to the "defaults" (i.e. the preferences) of the dock. This older MacRumors thread shows how to do that.
If you are not using PackageMaker, then you might have to run an Applescript from within your app that does the same "defaults" writing trick. Here's a thread on AskDifferent that shows how.
In both cases you need to kill the dock (or Finder?) and restart it in order to get the change to pick up and show.
来源:https://stackoverflow.com/questions/13451234/programmatically-add-application-icon-to-dock-on-install