What Xamarin is actually doing when using an iOS build host? What Xamarin is actually doing when using an iOS build host? ios ios

What Xamarin is actually doing when using an iOS build host?


A great explanation from here.

Xamarin.iOS compiles c# source code against a special subset of themono framework. This cut down version of the mono framework includesadditional libraries which allow access to iOS platform specificfeatures. The Xamarin.iOS compiler, smsc, takes source code andcompiles it into an intermediate language, ECMA CIL (commonintermediate language), however it does not produce ECMA ABIcompatible binaries unlike the normal mono compiler, gmcs or dmsc.This means any 3rd party .Net libraries you want to include in yourapplication will need to be recompiled against the Xamarin.iOS subsetof the mono framework using smsc.

Once a Xamarin.iOS application has been compiled into CIL it needs tobe compiled again into native machine code that can run on an iOSdevice. This process is carried out by the SDK tool ‘mtouch’, theresult of which is an application bundle that can be deployed toeither the iOS simulator or an actual iOS device, such as an iPhone oriPad.

Due to restrictions placed by Apple, the iOS kernel will not allowprograms to generate code at runtime. This restriction has severeimplications for software systems that run inside a virtual machineusing just-in-time compilation. Just-in-time compilation takes theintermediate code, for example mono CIL and compiles it at runtimeinto machine code. This machine code is compatible for the device itis running on at the time of execution.

To work around this restriction the mtouch tool compiles the CIL aheadof time. A process that the mono team describe as AOT, ahead of timecompilation.

enter image description here

Some quotes from Xamarin docs:

Xamarin iOS for Visual Studio accomplishes an amazing feat: it letsyou create, build and debug iOS applications on a Windows computerusing the Visual Studio IDE. It cannot do this alone, however - iOSapplications cannot be created without Apple’s compiler, and theycannot be deployed without Apple’s certificates and code-signingtools. This means that your Xamarin iOS for Visual Studio installationrequires a connection to a networked Mac OS-X computer to performthese tasks for you. Once configured, Xamarin’s tools will make theprocess as seamless as possible.

Starting with Xamarin.iOS 4.0, there are two code generation backendsto Xamarin.iOS. The regular Mono code generation engine and one basedon the LLVM Optimizing Compiler. Each engine has its pros and cons.

Typically, during the development process, you will likely use theMono code generation engine as it will let you iterate quickly. Forrelease builds and AppStore deployment, you will want to switch to theLLVM code generation engine.

Conclusion

So there is no way to make an iOS build host in Windows, as you said.

I guess Xamarin send to the build host the .Net assembly file (Orange part of the picture), to be compile into native ARM code using Apple llvm, and others tools like xcode-build to signed, link and build your application.