Xamarin last week announced version 8.6 of its iOS SDK (Xamarin.iOS), the first non-beta release to include the company's Unified API for iOS and Mac. The Unified API replaces the 32-bit MonoTouch and MonoMac APIs, enabling code re-use across both platforms and adding 64-bit support. The release comes just two weeks ahead of Apple's February 1st deadline for all new app submissions to be 64-bit compatible.
Xamarin's mobile development platform makes it possible to develop native cross-platform mobile apps using C#. The company has utilised the open-source Mono toolchain to create compatible runtimes for iOS and Android. On iOS an AOT (Ahead-of-Time) compiler compiles C# applications to native ARM assembly code. On Android C# is compiled to an intermediate language, which in turn is Just-in-Time (JIT) compiled on the device. Developers can therefore write their application once and execute it on iOS, Mac, Android and Windows Phone.
The new Unified API is not dissimilar to the classic MonoTouch API, however Xamarin have made two significant changes to facilitate cross platform code re-use and 64-bit compatibility:
- Removed Namespaces - the iOS and Mac specific namespaces have been removed and collapsed into a single namespace. For example the Foundation framework previously existed in the MonoTouch.Foundation namespace on iOS and MonoMac.Foundation namespace on Mac, but can now be found in the Foundation namespace on both platforms.
- New Native Types - In the Classic MonoTouch and MonoMac APIs, architecture independent types e.g. NSInteger (which resolves to an int on 32-bit devices and a long on 64-bit devices), were always mapped to their corresponding 32-bit .NET types. To rectify this limitation Xamarin have introduced three new native types - System.nint, System.nuint and System.nfloat, which are implicitly mapped to the appropriate backing type for the device architecture. The Unified API favours the use of these new native types in place of the .NET primitive types.
Developers wishing to update their apps to use the Unified API can either do so manually or avail of Xamarin's Migration Tool. Distributed as part of Xamarin Studio 5.7, the Migration Tool automates the required project settings and API reference updates. Alternatively, developers can opt to manually migrate their apps using the steps outlined in the Updating Existing iOS Apps guide. Xamarin provided additional information on both approaches in a Webinar earlier this week, a recording of which has been made available on the Xamarin blog.
As reported by InfoQ in December 2014, Xamarin have been seeding beta releases of the Unified API to developers of third party libraries and components, encouraging them to update their projects. However, not all third party components will have been updated. To work around this developers may have to migrate and compile the code for these components as part of their own project build.
Using the new Unified APIs developers will be able to compile 64-bit compatible iOS and Mac apss for the first time. This is particularly pertinent for developers working on new iOS apps, which in accordance with Apple's announcement in October must be 64-bit compatible as of February 1st 2015. Developers working on apps already published to the App Store have some added leniency and won't be required to add 64-bit compatibility in updates until June 1st 2015.