Platypus error: script missing from application bundle - ruby

My use-case was converting a ruby application into an executable app on a mac. When I created a release on github ... meaning users would download the project as a zip and run the program.
error message: script missing from application bundle
I had all checkboxes selected when creating application as shown:
I put my answer below. This was a quick solution. However, may not be best practice. If anyone puts forth a better answer determined by the community. I will make that the answer. The answer to this question regarding a ruby script should work for other scripts Platypus turns into .app's

My solution, after app is created;
right click .app file
select "show package" contents
navigate to path ...
Contents -> Resources
copy the script that you linked to ... in my case it was a ruby script.rb
delete the script alias names "script"
rename your copied script "script" without the .rb extension.
now since the script is inside the app
it will no longer have an issue finding the script location.

Related

Run file when .tar.gz file is opened

I am trying to make an executable link in an email for mac, so I don't want it to be a .exe file. I tried using a .command file so that it will run when you click on it, but it said it's from an unidentified developer and I don't want the recipient to have to change their security settings. So I want to use a .tar.gz file that has a shell script in it.
The problem is that when you click the link, it downloads but doesn't automatically run the shell script. I need to know when the file is unzipped so I can run the shell script inside. Does anyone know how to do that?
It isn't reasonable to expect to be able to run an arbitrary script on user's machine, without him explicitly asking to run it (e.g. if all he's doing is downloading a file, or opening a non-executable file).
If the OS allowed that, it would be a serious security breach.

Are "Validate" and "Distribute" steps necessary for Direct Distribution of a Mac app?

I am working to automate the process of releasing a Mac application using xCode 5. The app is only distributed outside of the Mac App Store (Direct Distribution). I know that I can add a Run Script to be executed during the Build Phase to automate the process. I am currently using a ruby script from Craig Williams for appcast automation. The script is here: https://github.com/CraigWilliams/appcastautomation/blob/SnowLeopard/appcast_automation.rb
My question is: Are the Validate and Distribute steps necessary? Provided that code signing is completed, can I simply run the automation script and use the .zip file produced by the script or must I go through the steps outlined below and then process the "Exported" app using the script?
My current process is as follows:
Select "Archive" from xCode's Product menu.
Open Organizer and press "Validate" button.
Press "Distribute" and choose "Export Developer ID-signed
Application" then press "Next".
Select my Developer ID code signing certificate.
Press "Export" to save the MyApp.app file.
Once I have the "Exported" .app file, I am manually running the script via Terminal to create the .zip file required for Sparkle appcast. I am hoping to skip the xCode export process as a first step towards automated distribution.
Yes, it is possible to completely automate an app release process without needing to go through Xcode's Organizer to "Validate" and "Distribute" an application for Direct Distribution. It requires several Run Script Build Phases to be added to the target in XCode. This is what I ended up doing...
1) The first step was to code sign all frameworks AND the application bundle so that when the appcast automation script runs, the app that gets zipped is already code signed. This omits the need to export the app via Organizer. This Run Script is added immediately after all "copy" build phases.
IDENTITY="Developer ID Application: My Great Company."
FRAMEWORK_LOC="${BUILT_PRODUCTS_DIR}"/"${FRAMEWORKS_FOLDER_PATH}"
codesign --verbose --force --sign "$IDENTITY" "$FRAMEWORK_LOC/Growl.framework/Versions/A"
codesign --verbose --force --sign "$IDENTITY" "$FRAMEWORK_LOC/Sparkle.framework/Versions/A"
codesign --verbose --force --sign "$IDENTITY" "$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME"
2) The 2nd Run Script executes a Ruby script that creates a .zip file of the app and an .xml file for appcast distribution via Sparkle. The original script came from here: https://github.com/CraigWilliams/appcastautomation/blob/SnowLeopard/appcast_automation.rb
I have customized the script to also copy the unzipped app to another folder that is later used to automagically create a .dmg file.
The 2nd run script is simply:
script_file="appcast_automation.rb"
$SRCROOT/$PRODUCT_NAME/${script_file}
3) The 3rd Run Script creates a .dmg file with a custom icon, background, version, license agreement, etc... I use DropDMG's command-line tool (http://c-command.com/dropdmg/) to create the .dmg file. I have added the wm_license and wm_layout directories into the Xcode project so the script has access to them and they are versioned using git.
This Run Script is set to "Run script only when installing".
VERSIONNUM=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
layout_folder="${PROJECT_DIR}/${PROJECT_NAME}/wm_layout"
license_folder="${PROJECT_DIR}/${PROJECT_NAME}/wm_license"
dmg_folder="/Users/username/Desktop/WindowMizer/${PROJECT_NAME}_$VERSIONNUM/${PROJECT_NAME}"
dropdmg --custom-icon --license-folder=$license_folder --layout-folder=$layout_folder $dmg_folder
The list of Run Scripts and the automation files in Xcode looks like this:
So, by simply choosing "Archive" in Xcode, I end up with: a .zip file and .xml files for automatic updates via Sparkle and a .dmg file for first-time (new) downloads. The end result is this...
Everything is code-signed and ready to deploy. The only thing left to do is to upload the files to the server, which could be automated, but I prefer to do that part manually.
When time permits, and if I am allowed, I will post my modified copy of appcast_automation.rb in a github repository and add a link to it from here.
Hope this helps someone else!

uploading and redownloading executable script

I have an executable terminal program (built on MacOS from Haskell code with GHC) which runs when I double-click it in the Finder. I want to put this on my website, from which people can download and run it from their Finder by double-clicking.
Somehow in this exchange the file loses the "+x" bit so that when it's re-downloaded it can't be run by double-clicking anymore. I can still run it but I have to do "chmod +x" first. What can I do so that the downloaded file will be executable by default? Do I have to package it inside a ".app" file? Right now it's ".command".
Regardless of whether it's part of an app bundle, the executable itself needs to be… executable. To ensure executability, you should put it in a zip or dmg file, which will preserve its 'executable' flag.
If you want to make it into an app bundle, there's a simple way to do that. If the executable is named PROGRAMNAME, then just put it in a folder called PROGRAMNAME.app. Double-clicking should run the file.
If you want to create a more proper app bundle, use this:
APP_NAME='My Awesome App.app'
EXE_NAME='PROGRAMNAME'
mkdir -p "$APP_NAME"/Contents
defaults write "`pwd`"/"$APP_NAME"/Contents/Info CFBundleExecutable "$EXE_NAME"
mkdir "$APP_NAME"/Contents/MacOS
cp "$EXE_NAME" "$APP_NAME"/Contents/MacOS
chmod a+x "$APP_NAME"/Contents/MacOS/"$EXE_NAME"
App bundles will not display Terminal output or report errors, so if you need that you should keep it as a raw executable. Also, simple apps made in the above manner will not have a GUI and will appear to not respond and will exit when they finish running.
Also, if you get the following message, it might be because the executable is too short (add more characters to it) or because of quarantining restrictions (try editing the executable and save it with an app like TextEdit to make it trusted).

Proxy shell script as app bundle executable

I create an app bundle which has a shell script as main executable.
This then runs "exec /path/to/other/executable" as its last action.
(The reason for this is that I download new executables through an update system, and I don't want to write into the app bundle which typically is in /Applications. Instead I write updates to the user directory, and aim to let the app bundle itself be just a kind of launcher)
The problem is that this makes OS X think that the bundle directory is the one in which the second executable is. This causes it to not respect Info.plist, and all kinds of badness. (If I move the real executable into the MacOS folder of the bundle, everything is peachy, but as I said this is not really an option)
This guide led me to believe that something like this was possible:
http://mjhutchinson.com/journal/2010/01/24/creating_mac_app_bundle_for_gtk_app
Here they run "exec mono ..." as the last action in their shellscript, where "mono" is a binary residing outside of the app bundle somewhere. And I assume their bundles end up being well behaved.
Is this possible then?

Generating a compiled application from an Apple Script

For an application uninstaller I use an Apple Script that I save in Apple Script Editor to a .app bundle. What I would like to do is to generate that .app bundle from the command line (so I can incorporate the step into an automated build script, and not have the bundle in a repo). Is this possible ? I have yet to find a command line interface to Apple Script Editor...
Edit: Just found osacompile... ;)
See the man page for the osacompile command.

Resources