16

I tried following a few tutorials, but I get this: PowerPC Error

How can I fix this? I added in a info.plist (I just copied and pasted another app's file, and changed around a few things.)

Also, I used chmod +x myApp to make the script executable.

P.S. I am using El Capitan

10
  • We can't guess what you did before getting the error message. Which tutorials did you follow, after which step did you get stuck?
    – nohillside
    Jan 21, 2016 at 21:18
  • 1
    I created a folder called myApp.app, then a sub folder called Contents, then MacOS, then a myApp shell script that contains #!/bin/bash ; say "Hi" ; exit 0 (With each of the commands on different lines, and w/o the semicolon).
    – Flare Cat
    Jan 21, 2016 at 21:26
  • 2
    A bash script that has it execute bit set doesn't necessarily need to be placed in a bundle to be executed, simple double-click it if just in Finder or run it from Terminal. If you really want an application bundle then create it using AppleScript or Automator, the latter of which is easy. Add a Run Shell Script action and place your code in it. Jan 22, 2016 at 11:54
  • @user3439894 I tried automater in the method you described before posting this, but the app would not run on the target computer.
    – Flare Cat
    Jan 22, 2016 at 20:04
  • @user3439894 Well, for some reason I can't edit my previous comment. The error was something like 'This type of application is not supported on this computer.'
    – Flare Cat
    Jan 22, 2016 at 20:24

3 Answers 3

34

Well, it's been years I use this simple trick to have bash scripts in application (and really really don't understand why all people try so complicated solutions as creating "Contents" folders, info.plist or use Automator or Platypus or so... ????).

  1. Create a folder named "YourApplication.app". It can be created at any location that is convenient to your usage. Though, the most OS compliant locations may be /Applications or your own ~/Applications folder.
  2. Put your script file directly in this folder the way that suites you the best (Finder, terminal etc). The script must be executable of course (use chmod +x if you need). No need for other folders or file (until you need to call other scripts or executable from within your script of course) The trick is to name your script with exactly the same name as the application folder but without extension. In the case described here the script file must be named "YourApplication".

That's all ! It works on Mac os x since Snow Leopard to Mavericks. If anybody can try on newer OS versions and tell me.

Note: The script must be at least 28 bytes in size, otherwise it will not execute. It may be padded with blank lines to achieve minimum size. Also, the first line of the script must be a shebang; e.g. #!/bin/bash or #!/bin/perl.

[UPDATE]

Answering what @DenisHowe's comment is addressing, when using this trick, if you want to have the path of the current execution, you can add those lines at the beginning of the script :

abspath () 
{ 
case "${1}" in 
    [./]*)
    local ABSPATH="$(cd ${1%/*}; pwd)/"
    echo "${ABSPATH/\/\///}"
    ;;
    *)
    echo "${PWD}/"
    ;;
esac
}


CURRENTPATH=`abspath ${0}`
PATH=$PATH:$CURRENTPATH
29
  • 1
    I've edited your answer to include the critical missing piece of information and up-voted it. Jan 16, 2017 at 16:14
  • 1
    I just tested this under macOS Sierra and it works there too. Jan 16, 2017 at 16:19
  • 1
    @FlareCat In fact, I just checked and I guess any shebang with an existing interpreter will do (tried with perl). If you tried other languages, just tell ;). Feb 11, 2017 at 16:24
  • 1
    Works under macOS Catalina too, thanks Jun 11, 2020 at 19:59
  • 1
    @basbebe Thanks for your report. I can't have Big Sur for the moment to look for a solution about the arguments (my two Macs are too old). But I will try as soon as I can. I guess a look in the documentation of "open" with --args may give some more clues. Jul 15, 2021 at 6:29
11

If it is a simple shell script, then you don't need to wrap it in an application bundle; you can double-click the script itself. However, you won't get the ability to have a custom icon or other things like that.

I think there are a few helpers out there that can wrap simple scripts, but the only one that I have experience with is Platypus which allows you to make shell/python/perl/ruby/etc scripts run like regular applications with icons, I/O redirections, etc.

Where Platypus differs here is that you CAN get STDIN / STDOUT through a few different mechanisms, as well as menu bar interactivity. So you get a window where you can interact with whatever script is actually running.

0
9

The currently accepted answer does not quite work for me. I get the little broken application icon.

enter image description here

The following works for me under OSX 10.15.7 (Catalina). You can feel free to change the YourApplication in all of the following instructions to be the name you really want.

  1. mkdir a directory with the .app extension in the /Applications folder with a Contents and then MacOS subdirectories.

    mkdir -p /Applications/YourApplication.app/Contents/MacOS
    
  2. Move your script into this directory and name it the same as the top application folder but without the .app extension and without the shell script extension:

    mv yourscript.sh /Applications/YourApplication.app/Contents/MacOS/YourApplication
    
  3. Make sure your script is executable:

    chmod +x /Applications/YourApplication.app/Contents/MacOS/YourApplication
    

Your application should now be ready and the script should run when you double click on it. It's important to note that if you rename the application, you will need to rename the underlying script.


To have your application seen by LaunchPad was harder to figure out. The following seemed to work. You need to add something like the following into the /Applications/YourApplication.app/Contents/Info.plist file. You might also need to move it over to a DMG file and back to Applications for LaunchPad to notice it. See: https://stackoverflow.com/a/71342335/179850

<?xml version="1.0" encoding="UTF-8" standalone="no"?><plist version="1.0">
  <dict>
    <key>CFBundleExecutable</key>
    <string>My App</string>
    <key>CFBundleGetInfoString</key>
    <string>My App 1.0</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
</dict>
</plist>

To add an icon to your new application, you need to do the following:

  1. Find or create a PNG that you want to be your icon.

  2. Open the image in the Preview application – other graphics apps may also work.

  3. Press command-a to select all and then command-c to copy it to the clipboard.

  4. Select your application in the Finder and press command-i to Get Info window.

  5. Click on the icon in the upper left corner of the info window to select it:

    enter image description here

  6. Paste the image from the clipboard which should change the icon.

    enter image description here

You can also open up the Get Info window on other application, select it's icon, and copy it so you can paste it onto your new application. After you assign any icon, if you look in your .app directory, you should see a filename that starts with Icon.

5
  • 1
    You don't need to have all those folders in the application one. Just put your script directly in the application root folder (i.e. /Applications/YourApplication.app in your case), and make it executable. It just needs to be at least 28 bytes in size and have a shebang, as any script should have. Dec 8, 2021 at 9:49
  • This is all very well, and it works as described, but none of it makes it visible to Launcher, which is the main reason I want to make my script into an "App" in the first place. Anyone can supply that last bit?
    – q.undertow
    Mar 2 at 23:45
  • What is launcher @q.undertow? Do you mean LaunchPad? Maybe instructions from here about dragging your new application to the LaunchPad icon? appletoolbox.com/…
    – Gray
    Mar 3 at 15:55
  • Yes, Launchpad, sorry. I'll try that link, but I don't want to mess with the system /Applications area - I have my script under ~/Applications. I had some downloaded apps in there and I remember Launchpad had no problem with that.
    – q.undertow
    Mar 3 at 18:02
  • I've added some additional instructions @q.undertow. My application now shows up in Launchpad. See if it works for you.
    – Gray
    Mar 3 at 18:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .