My earlier article "Building a Basic AppleScriptObjC (Cocoa-AppleScript) Application with Xcode" explained how AppleScriptObjC and Xcode can be used to build robust interface-based applications for the Mac. While that article demonstrated this principle through the creation of a very simple Hello World application, the techniques provided can serve as the basis for building more advanced applications, for real-world scenarios. In this article, we'll build on those techniques to create a functional application that can perform some basic image manipulations, including flipping, rotating, and scaling a chosen image.
If you want to follow along with the tutorial, download a functional copy of the completed application. Of course, it's also a good idea to have a working knowledge of AppleScript and a basic understanding of Objective-C. If you're new to either of these technologies, check out the suggested learning resources at the end of this article.
Creating the AppleScriptObjC Project
Start by launching Xcode, which you can find in the Mac App Store if you don't already have it. If the project template selection window doesn't appear automatically at launch, select File > New > Project to display it. Under OS X > Application, choose the Cocoa-AppleScript Application template and click Next (see Figure 1).
Figure 1 Choosing an AppleScriptObjC (Cocoa-AppleScript) Xcode project template.
When the options screen appears, enter a product name, such as My Image Processor, and fill in your organization name and company identifier (in reverse URL format; that is, com.mycompany). You can also choose an App Store category, although this is really only necessary for apps you intend to distribute through the Mac App Store. When you're done, click Next (see Figure 2).
Figure 2 Specifying options for your project.
Xcode now asks you to choose an output location for your project. Browse to the desired directory, such as your Desktop, and click Create (see Figure 3).
Figure 3 Choosing a location for your project.
Xcode builds and configures your project and then displays it in a window, ready for editing (see Figure 4).
Figure 4 A new AppleScriptObjC project in Xcode.