Xamarin iOS模拟器构建(Xamarin iOS simulator build)

有谁知道Xamarin为iOS模拟器构建是否与常规Xcode模拟器构建有所不同?

换句话说就是Xamarin模拟器构建“干净”的原生构建?

Does anyone know if Xamarin build for iOS simulator is somehow different from regular Xcode simulator build?

In other words is Xamarin simulator build "clean" native build?

最满意答案

正如Xamarin文档中所述 :

编译任何Xamarin平台应用程序时,Mono C#(或F#)编译器将运行并将您的C#和F#代码编译为Microsoft中间语言(MSIL)。 如果您在模拟器上运行Xamarin.Android,Xamarin.Mac应用程序,甚至是Xamarin.iOS应用程序,.NET公共语言运行库(CLR)使用即时(JIT)编译器编译MSIL。 在运行时,它被编译为本机代码,可以在您的应用程序的正确架构上运行。

但是,由Apple设置的iOS存在安全限制,不允许在设备上执行动态生成的代码。 为了确保我们遵守这些安全协议,Xamarin.iOS使用Ahead of Time(AOT)编译器来编译托管代码。 这会生成本机iOS二进制文件,可选择使用LLVM进行设备优化,可以部署在Apple的基于ARM的处理器上。

As stated in Xamarin docs:

When you compile any Xamarin platform application, the Mono C# (or F#) compiler will run and will compile your C# and F# code into Microsoft Intermediate Language (MSIL). If you are running a Xamarin.Android, a Xamarin.Mac application, or even a Xamarin.iOS application on the simulator, the .NET Common Language Runtime (CLR) compiles the MSIL using a Just in Time (JIT) compiler. At runtime this is compiled into a native code, which can run on the correct architecture for your application.

However, there is a security restriction on iOS, set by Apple, which disallows the execution of dynamically generated code on a device. To ensure that we adhere to these safety protocols, Xamarin.iOS instead uses an Ahead of Time (AOT) compiler to compile the managed code. This produces a native iOS binary, optionally optimized with LLVM for devices, that can be deployed on Apple’s ARM-based processor.

更多推荐