- Consider a
game.app
with agame
binary inside - Rename the binary file inside
Contents/MacOS/game
- let's sayContents/MacOS/thegame
- Create a new empty file where the binary was
Contents/MacOS/game
- Put the example.sh bash code inside of it.
- Change it to run
thegame
instead ofactual_binary
- make the new script executable with
chmod +x Contents/MacOS/game
- warning this permission can get stripped away on windows, zips, http etc.
- That's it!
The machination is: Info.plist has:
<key>CFBundleExecutable</key>
<string>game</string>
This tells the app what to run when double clicked.
Point it to a bash script that runs the game (and does other work ahead of that).
- watch out for paths not being relative
- watch out for modifying a code signed binary if doing mac app store
- watch out for losing
chmod +x
permissions - it might be preferable to make an actual macos binary using a native compiled language to execute things like this to be water tight, but this should work in all cases outside of obscure ones.