Installing Xamarin and other required components on your Windows PC and Mac

How does Xamarin work exactly? It does seem like magic, right? I mean, writing C# in Visual Studio and compiling a native iOS, Mac, or Android application on the other side does seem magical. A lot of technology has gone into giving developers the ability to do this. With iOS and Mac applications, the process is somewhat involved. One thing to be aware of if you want to target iOS or Mac is that you will need to use a Mac in order to build your iOS applications. There are services out there that make Macs available for remote testing and compilation (such as MacinCloud, http://www.macincloud.com/). These, however, do incur a monthly cost. When Xamarin compiles your C# code, it does so against a special subset of the Mono framework.

Mono is sponsored by Microsoft and is an open source implementation of the .NET Framework. This is based on the ECMA standards for C# and the Common Language Runtime. For more information on the Mono framework, take a look at http://www.mono-project.com/.

Looking at iOS specifically, this special subset includes libraries that allow access to iOS platform-specific features. The Xamarin.iOS compiler will take your C# code and compile it into an intermediate language called ECMA CIL. This common intermediate language (CIL) is then compiled a second time into native iOS code that an iPhone or iPad can run. You can then also deploy this to a simulator for testing. 

Now, you might be wondering why a Mac is needed to compile your application? Why can't it all just happen from within Visual Studio? Well, this is due to a (quite clever) restriction imposed by Apple on the ability of the iOS kernel to generate code at runtime. It simply does not allow that to happen. As you know (this is the extremely simplified explanation), when your C# source code is compiled for testing it is compiled into intermediate language. The just-in-time (JIT) compiler then compiles the intermediate language into assembly code that is appropriate for the architecture you are targeting. Because the iOS kernel does not allow this on-demand compilation by a JIT compiler, the code is statically compiled using ahead-of-time (AOT) compilation. 

To view the limitations of Xamarin.iOS, take a look at the following link:
https://developer.xamarin.com/guides/ios/advanced_topics/limitations/
For a list of available assemblies in Xamarin.iOS, Xamarin.Mac, and Xamarin.Android, take a look at the following support document:
https://developer.xamarin.com/guides/cross-platform/advanced/available-assemblies/.

The technology behind this is quite impressive. It is no wonder that Microsoft acquired Xamarin and included it as part of Visual Studio. Giving developers this array of choice for cross-platform development is what Microsoft is all about: empowering developers to create world-class applications.

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

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