问题
On Windows I'd simply add an RC file with the right data. Do I need to assemble a bundle as usual with an info.plist/version.plist or is there a better, standard, way of doing things? This is for Snow Leopard and later if that is relevant.
Thx++
回答1:
It is possible to embed an Info.plist file in an executable as a special Mach-o section. See for example this question.
回答2:
If you have a command line application, then it's just a single file and not a traditional OSX app package (with a Contents folder and a MacOS + Resources folder underneath).
If you're not willing to do a full blown Macintosh application package (with a GUI and an info.plist embedded somewhere in there), there are a few different things I've seen done with command line apps on the Macintosh.
1)
Add a "-v" option for version. So if you app is named foo, typing in "foo -v
" at the command line shows an output of "version 1.0
".
2)
Put the version number in as part of the filename... so "foo" is actually "foo1.0".
Oof, that seems clunky. So...
3)
Some apps have a symbolic link pointing to the real binary. So foo
points to foo1.0
and if you were to do a "ls -l", you'd see something like:
-rwxr-xr-x 1 root wheel 66128 Jul 12 15:39 foo1.0
lrwxr-xr-x 1 root wheel 15 Jul 12 15:39 foo -> foo1.0
so typing in "foo" at the command line would actually run foo1.0.
I hope these opinions help you out!
来源:https://stackoverflow.com/questions/8234946/adding-version-infomation-to-an-osx-command-line-application