Fun with AppleScriptObjC

johncwelch
New Contributor

aka "ASOC". Because if you are familiar with AppleScript, and wanted to do more, but don't have the time to immerse yourself into Objective-C, ASOC is a good bridge. Unlike the late, strange AppleScript Studio, (bearer of the worst acronym of any Apple product), ASOC is not some weird subset of ObjC or bizarrely limited in the same way ASS was. (I told you it was the worst acronym of any Apple product.)

with a few exceptions, fewer every release, there's nothing you can't do in an OS X app with ObjC that you can't do with ASOC. Note: OS X. There is no support within iOS for the AppleScript Runtime or anything else. This is an OS X-only option.

Also, please, no language wars. This is another way to get things done. It is not, in any way, saying anything bad about whatever language that is not ASOC that you like. No need to defend your language. Really.

So, this app, (project files here: https://www.dropbox.com/s/v09q3158j9sd923/SignatureGeneratorpublic.zip) was written because we had to add, basically, an entirely new company identity with separate email accounts and sigs. in this case, we wanted to use a company logo, and discovered, quickly, that Mail's own signature tools are...limited. To the point that embedding the image in the sig was failing all over the place, (our CEO is very particular about How Things Look), and we realized that part of the problem was that Mail generates...i'll be kind and say "suboptimal" HTML for sigs.

We had to generate our own HTML, and then make sure that Mail couldn't rewrite the sig later on. That latter part was easy, there's enough on google about that. The annoying part was creating the sig. We don't have a lab environment, and in fact, our users are highly mobile. In addition, since we're stuck with Google for our email provider, there wasn't a good way to set it up in their accounts in a way that would just add it on to every email they send. (Each sig is personalized. Gmail is not really good at such things. Google, for a provider of "enterprise" services often acts as if they have no real concept of what that may mean.)

So we had to be able to create the sig easily, and consistently, and if we didn't have to constantly edit HTML, even better.

Enter ASOC. Because there are multiple inputs, one optional, using "Display Dialog" isn't a really good idea. By using ASOC, we could do some sanity checking, (yes, you do in fact HAVE to have your email address in an email signature), and have a nice, proper window. If need be, we could, with only minor headaches, direct a remote person through using the app. Also, since it's written using Xcode, we can sign it, and so keep gatekeeper happy. Wins all the way around. (there's only 2.5 of us in IT, so I can yell down the hallway and most of the staff is notified. Makes life simple.)

rest of the details in the PDF. (Note: this doesn't even PRETEND to teach you ASOC. It's just a thing that might spark some interest. It also assumes some basic familiarity with Xcode.)

PDF link: https://www.dropbox.com/s/x8xbid2g4rdibl8/siggenerator.pdf

Also, there is actually a really good book on ASOC, from Shane Stanley. Regularly updated as new versions of Xcode and language updates come out: http://www.macosxautomation.com/applescript/apps/book.html

3 REPLIES 3

chriscollins
Valued Contributor

Thanks John. I think there was a post on your old web site a long time ago that sparked my interest in ASOC. Now we write a lot of our internal tools in ASOC including a custom deployment app focused around Casper as well. Really great for making certain processes that are otherwise too foreign for our non-Mac techs to be doable for them since we can put a really straight forward custom interface using ASOC.

bentoms
Release Candidate Programs Tester

AppleScript.. Woohoo!!

kalikkalik
New Contributor

ASOC is a nice bridge between languages.

I started out in AppleScript/Bash, then moved to AppleScript Studio (nightmare), and quickly moved to Objective-C since it was just way damn better. If ASOC was around back then, I probably would've adopted it for internal usage. I have to use mostly Objective-C these days since we're building for Mac and iOS, but again, ASOC is a nice step between languages, and can begin to help provide foundational elements for the heavier stuff in Obj-C.

-j