Chapter  30

An Overview of Mac OS X Development

Mac OS X makes an excellent development platform for a wide range of development. Not only are there tools and technologies available that allow you to create new Mac OS X applications, but you can also get your feet wet by extending the capabilities of the applications you already have. Mac OS X also is a great platform for developing services and applications for other platforms outside of Mac OS X.

In this chapter, we will take a wide look at the development landscape and provide a glimpse of the development platforms and technologies that fall outside of Apple's core development tools. We will broadly cover the following:

  • The types of software you can develop on Mac OS X
  • The types of platforms (other than Mac OS X and iOS) you can develop for
  • The types of third-party tools and technologies available for various types of development

NOTE: AppleScript, Automator, and Xcode will be covered in the following three chapters.

Scripts, Applications, and More

Most people think about development in terms of application development. That is, they assume developers write apps and nothing else. A typical daily conversation for a developer goes along these lines:

Person: “So, what do you do?”

Developer: “I'm a software developer.”

Person [excitedly]: “Oh, really? You know I had this idea for an app that will do this and that. Do you think you could create something like that?”

Developer [attempting to maintain their cool, but knowing where this is going]: “Well, yeah, maybe, but that's not really the sort of development I do.”

Person [puzzled expression appears on face]: “Oh, so what kind of apps do you make?”

Developer: “Well, not really apps; I develop business logic compon…blah blah blah….”

Person [backing away slowly]: “Oh… ummm... cool… well nice meeting you….”

The truth about development is that a large number of developers don't create apps (or at least they don't create just apps). This begs the question, what do developers develop? Well lot's actually:

Applications: For our purposes, an application is computer software that is written for a computer user to accomplish one or more specific tasks. This is a fairly broad term, and it is usually useful to further divide apps into smaller categories such as native apps, web apps, and widgets.

Utilities: A utility is computer software that performs one or more specific maintenance or general-purpose computing tasks that are designed to help analyze, configure, optimize, or maintain the computer system itself.

NOTE: Applications and utilities are occasionally confused. A good way to differentiate them is to consider that an application is designed so the computer can help accomplish a task for a user, while a utility is designed so a user can help accomplish a task for the computer.

Scripts: Scripts are generally user-created programs that are written to customize or automate the execution of another command or series of commands.

Frameworks or libraries: Frameworks and libraries are collections or reusable code that developers can use to simplify the development process.

Plug-ins: Plug-ins are pieces of software that can enhance the features of other software.

Components: Components are modular pieces of software in which related data or functions are encapsulated. Components can then be strung together to create custom applications.

NOTE: While the component model is quite popular in computing today, with it being used in many web and enterprise development technologies, it's not a model that is popular at Apple for development these days. Apple was once a big proponent of application-based component technology and even helped develop OpenDoc, a framework where individual, task-specific software components (i.e., a text component, a web component, a bitmap component) would be tied together to create a document-centric application environment. OpenDoc had a number of major problems and was scrapped, and while components are still used here and there (mostly on the OS level), Apple has never brought component technologies like OpenDoc back to applications

System software: System software includes operating systems (like Mac OS X) and software that helps govern computing resources. Some consider large-scale web-based systems to also fall into this category.

Device drivers: Device drivers control specific hardware components in modern computing systems. For any hardware to work with your computer, a device driver must be written for it.

Beyond the types of software listed here, there are many others, including embedded programming, firmware, and language development. While some forms of each of these software types can be (and are) regularly developed on Mac OS X, what we are going to concern ourselves with in the later chapters of this book are applications and scripting.

Platform Targeting

When you create any software, you need to choose a target platform; that is, you need to decide what computing environment you want your software to run in. Depending on the specific project, sometimes this is decided for you; other times you can choose. The most common platforms for development on Mac OS X are Mac OS X itself, iOS, and various web stacks. (A stack in this context is a collection of technologies that work together to create a development platform; a common stack is Apache, MySQL, and PHP (XAMP, where the X can be “L” for Linux or “M” for Mac). Of course, other platforms may be targeted from Mac OS X, including Java and even Android.

We will cover the Mac OS X and iOS stuff in the next three chapters (with a focus on Mac OS X, but many of the tools and frameworks apply for iOS as well). We touched a bit upon web development in Chapter 27. Let's take a quick look at some other platforms you can target from Mac OS X.

Java

Mac OS X and Java have an interesting history. Originally Java was an integral part of Mac OS X development, and Java was a fully supported alternative to Objective-C for Cocoa development. At the same time, though, there was often a discrepancy between the latest versions of the official Java SDK, Java Runtime Engine (JRE), and Java Virtual Machine (JVM) and what was available on Mac OS X (with Java for Mac OS X often lagging behind). To help solve the discrepancy, Apple started developing and maintaining Java releases for Mac OS X and managed to largely keep Mac OS X on par with other Java-enabled platforms.

With the release of Mac OS X 10.4 (Tiger), Apple announced that new additions to Cocoa would be written specifically for Objective-C, effectively signaling the end for Java as an official language for Cocoa development; however, Apple continued to support native Java development with frequent JDK releases.

In October 2010, Apple made yet another switch in its Java support stating that as of Mac OS X 10.6.3, Apple would deprecate its own version of Java and instead rely on Oracle, which now controls Java, for Mac OS X versions of Java. Since that time, however, Apple has continued to supply and update Java, at least for now.

Beginning with Lion, Java is no longer included with Mac OS X at all. Rather, the first time you attempt to access Java you will be prompted to install it through Software Update (Figure 30–1).

Image

Figure 30–1. The first time you try to use Java in Lion, you will be prompted to install Java from Software Update.

NOTE: While Java is still available from Apple, the question seems to be when, and not if, it will finally pull the plug on releasing Java. So, until Oracle gets on board with its own Mac OS X releases of Java, what can you do? Well, there are options; one of the most promising is the OpenJDK project that is a fully supported open source version of JDK Standard Edition (SE). OpenJDK is available eitherfrom http://openjdk.java.net or from MacPorts.

NOTE: Apple also has Java downloads available for registered developers from its Developer website.

Once Java is installed, it's ready to use for both running and developing Java applications (Figure 30–2).

Image

Figure 30–2. Eclipse is a popular development IDE written in Java. Here it is shown with a simple “Hello World” Java project open.

Despite the second-class status that Java seems to be receiving from Apple in Mac OS X these days, it's still a compelling platform since a native Java app should run on any platform with a Java runtime. Also, Java has found a strong niche in both enterprise and embedded systems development.

Android

Because Mac OS X is the only platform for native iOS development, countless mobile developers rely on it daily for their needs. Of course, iOS isn't the only mobile platform, and many mobile developers like the option of being able to develop for other platforms as well. Luckily, once you have Java installed, adding the necessary tools for Android development is a snap (especially if you have Eclipse, a Java-based IDE, shown in Figure 30–2, already installed). Not only can you develop android applications in Mac OS X, you can even run them using the Android emulator included with the developer tools (Figure 30–3). For details on how to get started with Android development, head over to http://developer.android.com.

Image

Figure 30–3. Mac OS X is an excellent platform for developing and testing Android applications. Here an Android tablet is being emulated to test applications.

POSIX Development

Portable Operating System Interface for Unix (POSIX) is a specification that allows developers to create applications on one POSIX-compliant platform and then easily port them to another POSIX-compliant platform. Along with systems like Solaris, AIX, HP-UX, and many other Unix and Unix-like OSs, Mac OS X is fully POSIX compliant.

NOTE: Most flavors of Linux, FreeBSD, NetBSD, and other popular open source platforms are not officially certified as such but are in fact largely POSIX compatible as well.

POSIX development usually revolves around the Unix tools available on Mac OS X that we covered in Chapters 23 and 24.

NOTE: In POSIX terms, portability is based on source code compatibility, not application compatibility. This means POSIX-compliant programs written in scripting languages should work unaltered from one POSIX platform to another (though certain path names and locations may very). However, compiled applications written in languages like C and C++ will need to be recompiled on each various platform. The recompilation, though, should be fairly pain-free. It is largely because of POSIX compliance that so much software is readily available from projects such as MacPorts.

Third-Party Tools and Technologies

A developer relies on their tools to help create applications, and Mac OS X has a large selection of tools for developers. Let look at just a sampling of some developer tools available from third parties.

NOTE: The next three chapters will cover Apple-branded development tools that are included either with Mac OS X line or as part of Xcode.

Text Editors

For a developer, a good general-purpose text editor can be a life-saver. Even though most integrated development environments (IDEs) have text editors (or text-editing capabilities) built in, sometimes you just want to quickly open a text file to make changes. Here are some of my favorites:

  • BBEdit ($49.99 in App Store): BBEdit is one of my all-time favorite tools for development. Not only has it been a top choice for web development for years, but its disk browser and Unix scripting support combined with unmatched text-editing capabilities make useful for any text editing you can throw at it.
  • TextWrangler (free in App Store): This is BBEdit's little brother (in fact, it was once BBEdit Lite). It lacks the features of BBEdit, but it's still a capable text editor.
  • TextMate (micromates.com): I hesitate to mention this app since it's been stuck at version 1.5.x for years (the last release was version 1.5.10, a minor update in November 2010) and little official word has been released about version 2 (which has allegedly been in development for more than four years). However, TextMate was at the time of its release an excellent highly customizable text editor that has attracted a large following. I can't really recommend running out and buying the current version; however, if TextMate 2 ever does appear, it should be worth checking out (after all, Duke Nukem Forever shipped, so at least there's hope).

Web Development Tools

Traditionally web developers just needed a good text editor, but today a number of extra tools are available that either provide a good addition to a text editor or provide a full-fledged web development environment with text-editing capabilities as well as much more. A few of the most interesting include the following:

  • Coda ($99.99 in App Store): Coda combines text editing, a visual CSS editor, file upload and download capabilities (including Subversion source control), a terminal, and more into a single application.
  • Espresso ($79.99 at macrabbit.com): Espresso is similar to Coda, yet it has some unique features. The current 1.1 release is solid, but there isn't much to recommend over Coda. The 2.0 release, which at the time of this wiring is in testing, promises to be excellent.

Mobile Development

Besides the native mobile development kits provided by Apple for iOS and Google for Android, there are a number of other ways to build native mobile Apps on Mac OS X. Two products (of many) that allow developers to use the latest web-based technologies to create native mobile applications are PhoneGap and Titanium Mobile.

NOTE: There has been discussion about Apple's policy of allowing third-party development tools for creating applications that can be distributed through the App Store. There are currently a large number of approved apps created by both of these products available on the iOS App Store, and to my knowledge no apps have been disapproved because they were built using either of these products.

PhoneGap (www.phonegap.com) is a framework developed by Nitobi Software that allows developers to create applications using HTML5 and JavaScript to leverage the native APIs and hardware features of mobile devices that can then be compiled into applications suitable for multiple mobile platforms including iOS, Android, BlackBerry, and webOS. Because this is a add-on framework (along with a custom JavaScript library), iOS development can take place in Xcode for easy iPhone testing and App Store deployment.

NOTE: To compile and deploy your application for various mobile platforms, you must be working in a native deployment environment. This includes iOS and Xcode, Android and Eclipse, and webOS with its SDK, which are all accessible from Mac OS X. BlackBerry development, however, requires Windows, so you will need a Windows system (or virtual machine) if you want to deploy your application to BlackBerry.

PhoneGap is released under either a BSD license or an MIT license, which makes it free to use and extremely flexible. (There are of course commercially available add-ons and support available.)

Titanium Mobile is developed by Appcelerator (www.appcelerator.com). Like PhoneGap, Titanium Mobile starts at the irresistible price of free and goes up for different add-ons and support options. Also like PhoneGap, developers use web-based technologies such as HTML and JavaScript to create the app that Titanium then converts to a native app. Unlike PhoneGap, Titanium uses its own IDE from development rather than each platform's specific tools, which makes cross-compiling much easier. Also unlike PhoneGap, while Titanium supportsonly iOS and Android for mobile apps, the Titanium platform extends to provide desktop application development for Mac OS X, Windows, and Linux.

Summary

If it's not immediately obvious, this is just a small smattering of the development tools and technologies available for developers who use Mac OS X as their primary development platform. The goal was to cover a range of what's available and let you fill in the gaps where necessary. Next, however, we will start to take a more detailed look at the development tools that Apple provides for Mac OS X, beginning with AppleScript and Automator.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset