While the tide may be changing, the fact remains that there are still far more C# developers today than there are Objective-C programmers. Yet as Apple's iOS platform continues to be a major player in the mobile computing landscape, more and more programmers are trying their best to learn the intricacies of the Objective-C language. Combined with the various frameworks Apple has created to give its iOS and Mac OSX platforms an edge in graphic flair and extensibility, learning these technologies is a tall order even for experienced programmers. Add to this the fact that Objective-C is an old language that only recently bolted on automatic object reference counting, its approach seems to harken back to a time when OO programming was a new concept before the widespread use of virtual machines, automatic garbage collection, and much of the syntactic sugar that helps programmers today. As a consequence of this situation, Xamarin has continued to refine its modern alternative to the Objective-C-centric iOS and OSX platform. Having achieved a modicum of success on iOS with MonoTouch (C# on iOS), Xamarin has repackaged that expertise with a C# alternative to the Objective-C approach for the Mac OSX desktop.
White PapersMore >>
- Catch the Security Breach Before It’s Out of Reach
- How to Protect Your Content and Improve Security with Cloud Client Computing and Thin/Zero Clients
Xamarin.Mac is a natural addition to the Xamarin family, which already includes C#-centric programming products for Android and iOS mobile platforms. The basis of this technology is the open source .NET framework called "Mono," which several members of the Xamarin team created while working at Novell before that company was acquired by Attachmate. While Xamarin's products don't technically belong in a cross-platform computing category, it's obvious that their main attraction is to offer the majority of C# programmers an easier alternative for Apple technology application development.
The ideal customer for Xamarin.Mac is one versed in using MonoTouch for iOS. MonoTouch developers will feel right at home with Xamarin.Mac because it uses the same IDE, MonoDevelop (Figure 1), the same workflow (Apple Xcode for creating the user interfaces), and many of the same frameworks and libraries used on iOS (since iOS is a subset of OSX). As someone who has used MonoTouch on and off for the past few years, I was able to create my first Xamarin.Mac-assisted native OSX application in a matter of minutes. Creating a native Mac application so quickly certainly gave me a cool feeling of productivity.
Loading up several Xamarin.Mac code examples posted on Github, it becomes apparent how extensively the Xamarin team took advantage of the broader number of libraries available on the OSX platform. Xamarin.Mac isn't merely a pure port of MonoTouch for iOS, but much more. Xamarin.Mac is a sign of the times, in that development tools for the mobile platform are the forerunners of their desktop programming counterparts, rather than the other way around.
Figure 1: The Xamarin.Mac development environment.
For those unfamiliar with the MonoTouch development experience, Xamarin.Mac is not just a copy of Visual Studio for the Mac. C# developers may have false expectations if they think of Xamarin's solutions in that way. While Xamarin.Mac uses the same syntax and many of the same underlying frameworks as C# and .NET, it only goes so far when it comes to incorporating Apple-specific technologies. Underlying system-level libraries like those that support networking, database interactivity, and the like are familiar territory for .NET developers, but stepping outside of those boundaries and into the Apple-specific user interface, graphics, and audiovisual territory, as well as the Apple App Store API and application security model, mean that the initial Xamarin.Mac learning curve can be long and daunting.
Before installing Xamarin.Mac, you need to have Apple's Xcode development environment already set up on your Mac system because Xamarin.Mac uses both its tools and libraries for application development, compilation, and testing. Setting up Xamarin.Mac consists of downloading a program that pulls down and installs the Mono Framework, MonoDevelop IDE, and the MonoMac add-in.
Figure 2: Xamarin.Mac shows up shows up as Xamarin.Mac in the MonoDevelop IDE Add-in Manager dialog.
Once the Xamarin.Mac license is successfully activated, you can opt to create a new Mac OSX project or load an existing project into the MonoDevelop IDE. In addition to a simple "Hello, World" walk-through example available on Xamarin's website, Xamarin has also posted several useful examples on their Github pages. These examples range from CoreText and CoreAnimation demos to CoreLocation, PDF generation, and embedding QuickTime features into your applications.
If you're a C# developer coming from the incredibly rich Microsoft Visual Studio IDE, it will take you some time to get used to the disconnected nature of using Xcode's Interface Builder to construct the user interface and then graphically wire these interfaces up to event handlers in your code. Xamarin's Hello, World example shows the amount of work needed to display such a simple message in a window.
Fortunately, once you get the hang of this Apple-centric development approach, app creation becomes relatively intuitive. Still, I do miss the simplicity of the integrated drag and drop UI linkages that traditional .NET and C# development have to offer on the Windows platform. Consequently, if you intend to use Xamarin.Mac with your C# skills, plan on spending a week or more to ramp up. Not only are there many nuances that have to be understood in the MonoDevelop/Xcode connection, but learning the Mac frameworks can be as daunting (if not more so) than the Windows .NET assemblies. Fortunately, if you are an experienced C# developer, you already have the advantage of knowing both the language and the system-level .NET assemblies that Xamarin has ported to Mono.
One of the weak areas of the product is documentation. It's incomplete, and Xamarin acknowledges as much on their site. (This was also the case when the company's MonoTouch first came out.) Still, depending on what aspects of Mac OSX programming you intend to pursue, it worthwhile checking Xamarin.Mac's online documentation before purchasing a license to ensure that you won't be out on a coding limb with an undocumented issue.
Figure 3: Xamarin.Mac documentation is a work in progress.
From the examples and the handful of Xamarin.Mac-assisted applications I created, I could see little discernible difference between them and an Objective-C-constructed counterpart (Figure 4). The application performance is unquestionably faster than Perl, Python, Ruby, or AppleScript bridge bindings that were a semi-Apple-supported alternative to Objective-C-based apps in the earlier days of OSX. Plus, all the benefits of C# and .NET assemblies come along for the ride with automatic garbage collection and easier-on-the-eyes syntax. Overall, Xamarin has delivered on performance while exploiting the advantages of C# programming on the Mac.
Figure 4: The Xamarin.Mac Button Example native OSX application.
Xamarin.Mac is a natural and obvious fit for the company's portfolio of C#/.NET-inspired multi-platform development tools. MonoTouch developers looking to expand their program offerings to the Mac platform will be immediately productive with Xamarin.Mac. Newcomers, especially those coming from the Microsoft universe, will need to account for the learning time necessary to understand the Xamarin-Apple development tools and workflow a process made more difficult by insufficient documentation. Nonetheless, if you're a C# fan and not interested in learning Objective-C but still need to write and deploy your custom applications on the Mac desktop, Xamarin.Mac is the best tool for the job.
Xamarin.Mac Professional, reviewed here, costs $399 per license and is available for purchase from Xamarin's online store. It grants name-based license holders the ability to publish their applications only to Apple's App Store (a separate Apple Developer account is required to do this, however). The enterprise version ($999) provides licensing rights for internal distribution. It is designed for companies that need seat-based licensing for their teams. This means that you can provision this license to a single active developer, and reprovision it as your team scales. Finally, Enterprise Priority (2499) adds a one-day support SLA, plus the ability to schedule time with a Xamarin Engineer to talk through specific questions or problems.
Mike Riley is a blogger for Dr. Dobb's and has been a judge for the Jolt Awards for more than 15 years.