Using Automator.app and Platypus.app, I have been able to bundle a simple shell script I created to power cycle wi-fi on my MacBook Pro. Both resulting apps run properly, but have one glaring issue that I want to correct: The apps reference the shell script from outside of the program. How can I embed the shell script and reference it from the app's resources so that the app can run even if the original source file is moved?
Best How To :
Just to mention it, if you Get Info on a script, you can set it to be opened with the Terminal. This will run the script when you double-click it.
Otherwise, packaging a script in a .app bundle is trivial. Mac OS X will happily run any script identified as the application's executable.
You need to have this file structure in place:
Files in italic are actual files, the rest are directory.
Only one entry is required in Info.plist, and it's the one that identifies MyScript as the application's executable:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
MyScript can be any script, with execution permissions and the correct shebang. Here's one that uses
/bin/sh as the interpreter, but you really could have anything (
open -a Calculator
The script will run as you double-click the app bundle.
You can bundle anything else that you need with your script within the
Contents directory. If you feel fancy, you can reproduce the standard executable bundle layout with a
Resources directory and things like that.