简体   繁体   English

Xamarin在使用iOS构建主机时实际上在做什么?

[英]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. 我注意到Xamarin有可能将Visual Studio连接到iOS构建主机。

What is this build host, is there any documentation about its architecture? 什么是构建主机,是否有关于其架构的文档? What code does Xamarin.iOS send to this build host? Xamarin.iOS向此构建主机发送了什么代码?

[Edit] [编辑]

I want, as a personal project, make an iOS build host in Windows. 作为个人项目,我希望在Windows中构建iOS构建主机。 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. 我关心的是原始iOS构建主机的架构。 I want to know what is the communication between Xamarin and a iOS build host, and what is the build flow. 我想知道Xamarin和iOS构建主机之间的通信是什么,以及构建流程是什么。 And this is not documented. 这没有记录。

A great explanation from here . 这里有一个很好的解释。

Xamarin.iOS compiles c# source code against a special subset of the mono framework. Xamarin.iOS针对单声道框架的特殊子集编译c#源代码。 This cut down version of the mono framework includes additional libraries which allow access to iOS platform specific features. 单声道框架的这个简化版本包括允许访问iOS平台特定功能的附加库。 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. Xamarin.iOS编译器smsc获取源代码并将其编译为中间语言ECMA CIL(通用中间语言),但它不会生成ECMA ABI兼容的二进制文件,这与普通的单编译器,gmcs或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. 这意味着您希望包含在应用程序中的任何第三方.Net库都需要使用smsc针对单声道框架的Xamarin.iOS子集进行重新编译。

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. 将Xamarin.iOS应用程序编译成CIL后,需要将其再次编译为可在iOS设备上运行的本机机器代码。 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. 此过程由SDK工具“mtouch”执行,其结果是可以部署到iOS模拟器或实际iOS设备(如iPhone或iPad)的应用程序包。

Due to restrictions placed by Apple, the iOS kernel will not allow programs to generate code at runtime. 由于Apple的限制,iOS内核不允许程序在运行时生成代码。 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. 即时编译采用中间代码,例如单声道CIL,并在运行时将其编译为机器代码。 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. 要解决此限制,mtouch工具会提前编译CIL。 A process that the mono team describe as AOT, ahead of time compilation. 单声道团队描述为AOT的过程,提前编译。

在此输入图像描述

Some quotes from Xamarin docs: 来自Xamarin文档的一些引用:

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. Xamarin iOS for Visual Studio实现了惊人的壮举:它允许您使用Visual Studio IDE在Windows计算机上创建,构建和调试iOS应用程序。 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. 然而,它不能单独执行此操作 - 如果没有Apple的编译器,则无法创建iOS应用程序,并且如果没有Apple的证书和代码签名工具,则无法部署它们。 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. 这意味着您的Xamarin iOS for Visual Studio安装需要连接到联网的Mac OS-X计算机才能为您执行这些任务。 Once configured, Xamarin's tools will make the process as seamless as possible. 配置完成后,Xamarin的工具将使流程尽可能无缝。

Starting with Xamarin.iOS 4.0, there are two code generation backends to Xamarin.iOS. 从Xamarin.iOS 4.0开始,Xamarin.iOS有两个代码生成后端。 The regular Mono code generation engine and one based on the LLVM Optimizing Compiler. 常规的Mono代码生成引擎和基于LLVM优化编译器的引擎。 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. 通常,在开发过程中,您可能会使用Mono代码生成引擎,因为它可以让您快速迭代。 For release builds and AppStore deployment, you will want to switch to the LLVM code generation engine. 对于发布版本和AppStore部署,您需要切换到LLVM代码生成引擎。

Conclusion 结论

So there is no way to make an iOS build host in Windows, as you said. 因此,正如你所说,没有办法在Windows中构建iOS构建主机。

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. 我猜Xamarin向构建主机发送.Net程序集文件(图片中的橙色部分),使用Apple llvm编译成本机ARM代码,以及xcode-build等其他工具来签名,链接和构建应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用VS2012和Build Host时如何从Xamarin.iOS中的类库链接第三方dll - How to link third party dll from class library in Xamarin.iOS when using VS2012 and Build Host Xamarin iOS Mac Build主机端口号 - Xamarin iOS Mac Build Host Port Number Xamarin.iOS 中的“必需的后台模式”实际上是什么意思? - What Does “Required Background Modes” In Xamarin.iOS Actually Mean? Xamarin iOS | 从Windows上的Visual Studio连接Xamarin Build主机时出错 - Xamarin iOS | Error Connecting Xamarin Build Host from Visual Studio on Windows Xamarin中的iOS构建大小 - iOS Build size in Xamarin 我们实际上在用代码中的属性做什么? - What we are actually doing with property in code? UIWebView scalesPageToFit属性,它实际上在做什么? - UIWebView scalesPageToFit property, what is it actually doing? 当与核心位置管理器对象一起使用时,initWithCoder实际上在做什么? - What is initWithCoder actually doing when used in conjunction with a core location manager object? 与Xamarin.iOS Build Host的连接失败。 双击此处尝试重新连接/选择服务器 - Connection to Xamarin.iOS Build Host failed. Double click here to attempt to reconnect/select a server 是否可以使用免费许可证在 mac 主机上为 vs2015 构建 xamarin.ios 应用程序? - Is it possible to build xamarin.ios applications on mac host for vs2015 with free license?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM