Biz & IT —

MonoTouch drops .NET into Apple’s walled app garden

Novell has launched a new SDK for the iPhone that will allow developers to …

Apple's iPhone is known for its Byzantine application approval process and somewhat insular platform. Undeterred by these challenges, Novell has succeeded in bringing Mono, its open source implementation of Microsoft's .NET framework, to the iconic device.

Novell announced Monday the official launch of MonoTouch, a new framework that allows application developers to build native iPhone software with C# and other .NET programming languages. It is designed to conform with the requirements stipulated by Apple for App Store eligibility. This will allow .NET developers to take advantage of their existing skills and potentially reuse some of their existing code when they build software for the iPhone.

MonoTouch applications will have a fully native look and feel and will be indiscernible from conventional iPhone applications.

Apple forbids the inclusion of mechanisms that enable execution of arbitrary third-party code. This rule effectively bars the use of nonstandard runtimes, JIT engines, and bytecode interpreters. In theory, that seems like an insurmountable obstacle for intrepid developers who want C# on the iPhone. In practice, it turns out that this challenge is not impossible to overcome. The developers behind the Mono project use static compilation to bring C# to Apple's platform without falling afoul of the App Store rules.

Mono typically uses a just-in-time (JIT) compilation model where bytecode is translated into native machine code at runtime. But the compiler also supports an alternate model called ahead-of-time (AOT) compilation, which will convert .NET Common Intermediate Language (CIL) into native code at compile-time. This makes it possible for developers to statically compile their Mono-based applications into native executables that do not require a VM or any other specialized runtime components, thus meeting Apple's strict requirements.

We first explored the potential of Mono on the iPhone in January when we looked at Unity, a 3D engine built on Mono that is used by a growing number of games that are available from the App Store. Unity also takes advantage of the AOT compilation approach and has proven that Apple considers it acceptable.

MonoTouch doesn't include support for WinForms or WPF. Instead, it introduces a comprehensive set of bindings for Cocoa user interface widgets and other standard iPhone APIs. This means that MonoTouch applications will have a fully native look and feel and will be indiscernible from conventional iPhone applications. The downside, however, is that MonoTouch developers will have to rewrite the user interfaces for their existing .NET applications when they port them to the iPhone.

"We decided instead to go with a native binding [for] the iPhone APIs. It would not be a cross platform API and it would tie developers to the iPhone platform, but it would also mean that applications would look and feel native, and developers would get closer to the iPhone," Mono developer Miguel de Icaza explained in a blog entry.

When the MonoTouch developers tested their APIs by porting Apple's iPhone code examples from Objective-C to C#, they discovered that the C# versions required considerably less code. C# is arguably a more expressive language in several key ways. In particular, de Icaza points out that C# constructor initializers help reduce the amount of code that is required to set up widget properties.

To simplify the application development workflow, MonoTouch includes add-ins for the MonoDevelop IDE that support integration with Apple's Interface Builder. MonoTouch also supports the iPhone simulator which will allow developers to test software without having to run it on an actual device.

As MonoTouch necessitates static linking, users will need a commercial license. This will cost $999 per seat for the enterprise edition and $399 per seat for the personal edition and will include one year of updates. For additional details, you can refer to the MonoTouch website.

Channel Ars Technica