简体   繁体   中英

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

I've noticed that there is a possibility in Xamarin to connect Visual Studio to an iOS build host.

What is this build host, is there any documentation about its architecture? What code does Xamarin.iOS send to this build host?

[Edit]

I want, as a personal project, make an iOS build host in Windows. I know that this can be achieved, and I'm sure that technically, I have all the needed tools to re-create one. My concerns is about the architecture of an original iOS build host. I want to know what is the communication between Xamarin and a iOS build host, and what is the build flow. And this is not documented.

A great explanation from here .

Xamarin.iOS compiles c# source code against a special subset of the mono framework. This cut down version of the mono framework includes additional libraries which allow access to iOS platform specific features. The Xamarin.iOS compiler, smsc, takes source code and compiles it into an intermediate language, ECMA CIL (common intermediate language), however it does not produce ECMA ABI compatible binaries unlike the normal mono compiler, gmcs or dmsc. This means any 3rd party .Net libraries you want to include in your application will need to be recompiled against the Xamarin.iOS subset of the mono framework using smsc.

Once a Xamarin.iOS application has been compiled into CIL it needs to be compiled again into native machine code that can run on an iOS device. This process is carried out by the SDK tool 'mtouch', the result of which is an application bundle that can be deployed to either the iOS simulator or an actual iOS device, such as an iPhone or iPad.

Due to restrictions placed by Apple, the iOS kernel will not allow programs to generate code at runtime. This restriction has severe implications for software systems that run inside a virtual machine using just-in-time compilation. Just-in-time compilation takes the intermediate code, for example mono CIL and compiles it at runtime into machine code. This machine code is compatible for the device it is running on at the time of execution.

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

在此输入图像描述

Some quotes from Xamarin docs:

Xamarin iOS for Visual Studio accomplishes an amazing feat: it lets you create, build and debug iOS applications on a Windows computer using the Visual Studio IDE. It cannot do this alone, however - iOS applications cannot be created without Apple's compiler, and they cannot be deployed without Apple's certificates and code-signing tools. This means that your Xamarin iOS for Visual Studio installation requires a connection to a networked Mac OS-X computer to perform these tasks for you. Once configured, Xamarin's tools will make the process as seamless as possible.

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

Typically, during the development process, you will likely use the Mono code generation engine as it will let you iterate quickly. For release builds and AppStore deployment, you will want to switch to the LLVM 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM