ScriptEditor

Latest

  • SDK devsugar: Re-signing applications

    by 
    Erica Sadun
    Erica Sadun
    02.09.2010

    TUAW's devsugar series helps introduce developers to tools and tricks that they might not yet be familiar with. Today's tip centers on signing already-compiled and already-signed applications with a new custom signature. A while back, I posted about a way to sign already-compiled applications with your personal credentials in order to better allow developer-to-developer distribution. By re-signing an application, it allows you to install it on any of the devices you have registered to your account at Apple without having to go through the fuss and bother of normal ad-hoc distribution. In addition, it makes it easier to develop applications on a contractor's machines, to ship them to a client, and then have them signed and shipped to App Store using the client's identity. A basic command-line solution is as follows. It calls codesign (found in /usr/bin) to sign the application, using the default keychain item that matches "iPhone Developer". It's a handy script, especially for informal beta distributions. #! /bin/bash export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate codesign -f -s "iPhone Developer" $1 There are, however, several problems with this approach. First, it assumes you only want to sign with development (typically "Debug build") credentials. That's not going to work if you need to re-sign for distribution. (Solution? Change iPhone Developer to iPhone Distribution). Second, it assumes you only have one developer or distribution profile in your keychain. (Solution? Change iPhone Developer, for example, to iPhone Developer: Company Name to exactly match just one keychain entry.) Third, it assumes the person doing the re-signing knows how to use a command line. For that, the solution is a little more complicated. Recently, this topic came up on a developer e-mail list that I moderate: how do you make it easier for a non-technical client to re-sign an application, normally for distribution. As a solution, I put forth the proposal that one could embed the above shell script behavior into an AppleScript droplet. After consulting with a few colleagues, and gathering their requirements, I decided to give the project a try. I built an AppleScript application that signs any application dropped onto it. You can find a working copy of the application at my website. App Signer iterates through any apps dropped onto it, checks to ensure whether each file (or bundle, really) ends with an ".app" extension, and then attempts to sign those files using /usr/bin/codesign. Users can choose to sign with Developer credentials, Distribution credentials, or select Other to open a prompt and enter text for keychain disambiguation. (See the screen shot at the top of this post for an example of the disambiguation dialog.) The application displays results for each application, one at a time. Please note the following caveats: I make no attempt to guarantee that the app dropped onto this utility is actually an iPhone app (rather than, say a Macintosh application). When working with on-device keychains, the identity used to sign the application has to match the application id set forth in the Info.plist file for the application, otherwise keychain access will fail. This is a free application. It is offered under the BSD license. Use it at your own risk. Credit always appreciated. The open source github repository for App Signer can be found here. To create the application, open the AppleScript source in Script Editor and choose File > Save As > File Format: Application.

  • AppleScript: Taking screenshots

    by 
    Cory Bohon
    Cory Bohon
    07.07.2008

    Last week, Dave mentioned that you can change the file type used system-wide for screenshots. However, some people are afraid of using Terminal.app to muck around with their Mac. In this week's AppleScript article, I am going to show you how to take screenshots and change their file type using an AppleScript.The AppleScriptproperty N : 0set N to N + 1set picPath to ((POSIX path of (path to desktop)) & "Picture_" & N & ".png") as stringdo shell script "screencapture -tjpg " & quoted form of picPathUsing the AppleScriptOpen the ScriptEditor (/Applications/AppleScript/ScriptEditor.app). Copy/paste the AppleScript into the script edtitor and click the run button at the top. You will hear the camera shutter sound and a picture will be taken and saved to your desktop. This script comes in handy when you want to take a screenshot in a different format. To do this, just change the ".png" file type to whatever you might want (say, .jpg, .tiff, etc.). When you re-run the script, the new file type will be associated with the capture image. Continue reading to learn how to save this script.

  • Mac Automation: create a Mail-triggered "spy cam"

    by 
    Cory Bohon
    Cory Bohon
    04.22.2008

    Have you ever been away from your Mac, then come back only to find that your co-worker has stolen your favorite Apple pen? Well, I am going to show you how to catch them in the act by creating a Mac "spy cam." For this how-to, you will need to create an Automator workflow, AppleScript, and some Mail rules. So, cue the James Bond music, and let's begin. You do need an iSight or a newer Mac with a built-in camera. (Yes, I know there are some tools prebuilt to do this -- but what's the fun in that?)Continue reading to learn how to create the Mac spy cam.