OSX 10.11 incorrectly sees application as powerPC

I reproduced this error on OS X El Capitan version 10.11.6 and found a workaround:

Error:

You can't open the application "Open_todo_in_vim" because PowerPC applications are no longer supported

Picture: enter image description here

How to Reproduce the error:

Full reproduction instructions found here: https://mathiasbynens.be/notes/shell-script-mac-apps

Jist:

Save this as appify.sh

#!/usr/bin/env bash

APPNAME=${2:-$(basename "${1}" '.sh')};
DIR="${APPNAME}.app/Contents/MacOS";

if [ -a "${APPNAME}.app" ]; then
    echo "${PWD}/${APPNAME}.app already exists :(";
    exit 1;
fi;

mkdir -p "${DIR}";
cp "${1}" "${DIR}/${APPNAME}";
chmod +x "${DIR}/${APPNAME}";

echo "${PWD}/$APPNAME.app";

Save it as /usr/local/bin/appify.sh, which requires root privileges give it executable permissions and then run it like so:

$ appify your-shell-script.sh "Your App Name"

Double click on "Your App Name".

Observe the error shown above.

Why is this annoying error happening?

It's a combination of many reasons:

  1. Safety: The developers over at Apple are fighting cybercrime with scripts in the background replacing your docked items. Roadblocks make successful viruses of yesteryear hit a brick wall. This is one of those walls.

  2. Money: The developers over at Apple want you to use their applications, not the applications you found over the internet because every app you use is a potential attack vector from unscrupulous developers worldwide.

  3. Protecting users from themselves: Apple developers only want power users to created docked items, you don't want novices figuring out "Hey! Anyone can drag some_low_level_guts_script.sh to the OSX dock and it solves my problem! Apple prevents this for the same reason parents keep bleach under the sink behind locked doors when toddlers are around.

Hacky Workaround so you can run your script without the PowerPC application error:

I found the answer that explains how to execute Shell Scripts from the OS X Dock here: https://stackoverflow.com/a/21048589/445131

Jist of Hacky workaround

  1. Create your shell script whatever.sh
  2. Make your shell script executable.
  3. Rename your whatever.sh to have a .app suffix: whatever.sh.app
  4. Drag whatever.sh.app to the OSX dock.
  5. Rename your script back to whatever.sh.
  6. Right-click the file in Finder, and click the "Get Info" option.
  7. At the bottom of the window, set the shell script to open with the terminal.

And the error mentioned at top no longer occurs. Double clicking the file on the OSX dock runs the shell script as expected without error.