32/64 位平台注意事项32/64-bit platform considerations

尽管 iOS 和 macOS 一直支持32和64位应用,但 Apple 已逐渐弃用32位支持。While iOS and macOS have historically supported both 32 and 64-bit apps, Apple has gradually deprecated 32-bit support.

从 iOS 11 开始,32位应用将不再启动,应用商店的所有提交都必须支持64位As of iOS 11, 32-bit apps will no longer launch, and all submissions to the App Store must support 64-bit.

从2018年1月开始,提交到 Mac App Store 的新应用必须支持64位,并且现有应用必须由6月2018更新。Starting in January 2018, new apps submitted to the Mac App Store must support 64-bit, and existing apps must be updated by June 2018.

Xamarin 的 Classic API (XamMac.dllmonotouch.dll)仅支持32位应用程序。Xamarin's Classic API (XamMac.dll and monotouch.dll) supported only 32-bit applications. 但是,新的 Xamarin 和 Xamarin 应用程序默认使用Unified APIXamarin.iOSXamarin.Mac),因此,在必要时可以同时针对32和64位。However, new Xamarin.iOS and Xamarin.Mac applications use the Unified API (Xamarin.iOS and Xamarin.Mac) by default, and can therefore target both 32 and 64-bit, as necessary.

iOSiOS

启用 Xamarin iOS 应用的64位版本Enabling 64-bit builds of Xamarin.iOS apps

警告

出于历史原因,此部分包括在内,有助于将较旧的 Xamarin iOS 项目移到 Unified API 并支持64位。This section is included for historic reasons, and to help move older Xamarin.iOS projects to the Unified API and support 64-bit. 默认情况下,所有新的 Xamarin iOS 项目都将使用 Unified API 和目标64位。All new Xamarin.iOS projects will use the Unified API and target 64-bit by default.

对于已转换为 Unified API 的 Xamarin iOS 移动应用程序,开发人员必须手动将生成设置更新为面向64位:For Xamarin.iOS mobile applications that have been converted to the Unified API, developers must manually update the build settings to target 64-bit:

  1. Solution Pad中,双击应用程序的项目,打开 "项目选项" 窗口。In the Solution Pad, double-click the app's project to open the Project Options window.

  2. 选择 " IOS 生成"。Select iOS Build.

  3. 对于 iPhone 模拟器,请在 "支持的体系结构" 下拉列表中,选择 " x86_64 " 或 " i386 + x86_64":For the iPhone Simulator, in the Supported architectures dropdown, select either x86_64 or i386 + x86_64:

    将支持的体系结构设置为 x86_64 或 i386 + x86_64Setting Supported architectures to x86_64 or i386 + x86_64

  4. 对于物理设备,请选择可用的ARM64组合之一:For physical devices, select one of the available ARM64 combinations:

    将支持的体系结构设置为 ARM64 组合之一Setting Supported architectures to one of the ARM64 combinations

  5. 单击“确定”。Click OK.

  6. 执行干净的生成。Perform a clean build.

ARMv7s 仅支持 iPhone 5 (或更高版本)中包含的 A6 处理器。ARMv7s is supported only by the A6 processor included in the iPhone 5 (or greater). ARMv7 代码比 ARMv6 更快且更小,仅适用于 iPhone 3GS 和更高版本,并且在面向 iPad 或最低 iOS 版本5.0 时,Apple 需要此代码。ARMv7 code is faster and smaller than the ARMv6, only works with the iPhone 3GS and later, and is required by Apple when targeting the iPad or a minimum iOS version of 5.0. ARMv6 适用于所有设备,但在 Xcode 4.5 和更高版本随附的编译器中不再支持该功能。ARMv6 works on all devices but is no longer supported by the compiler shipped with Xcode 4.5 and later.

需要 ARM64 来支持 iPhone 6 或其他64位设备上的 iOS 8,并将在 iTunes 应用商店中提交新的或更新现有应用程序时 Apple 要求使用。ARM64 is required to support iOS 8 on iPhone 6 or other 64-bit devices and will be required by Apple when submitting new or updating exiting applications in the iTunes App Store.

若要全面了解各种 iOS 设备的功能,请查看 Apple 的设备兼容性文档。For a comprehensive look at the capabilities of various iOS devices, check out Apple's Device Compatibility document.

64位和二进制大小增加64-bit and binary size increases

在 Apple 从32位转换到64时,iOS 应用需要在32位和64位硬件上运行。During Apple's transition from 32-bit to 64-bit, iOS apps will need to run on both 32-bit and 64-bit hardware. 因此,Xamarin 的 Unified API 允许开发人员以这两种方法为目标。Because of this, Xamarin's Unified API allows developers to target both.

面向32位和64位体系结构的目标会显著增加应用程序的大小。Targeting both 32-bit and 64-bit architectures will significantly increase the size of an application. 不过,这样做会允许较新的设备运行优化的代码,同时仍支持较旧的设备。However, doing so will allow newer devices to run optimized code while still supporting older devices.

重要

如果在向 iTunes 应用商店提交 iOS 应用程序时收到以下消息,则为 "警告 ITMS-9000:缺少64位支持。从2015年2月1日开始,已上传到应用商店的新 iOS 应用必须包括64位支持,并通过 iOS 8 SDK (包括在 Xcode 6 或更高版本中)构建。若要在项目中启用64位,建议使用默认的 Xcode 生成设置 "标准体系结构" 以使用32位和64位代码生成单个二进制文件。 "If you receive the following message when submitting an iOS application to the iTunes App Store, "WARNING ITMS-9000: Missing 64-bit support. Starting February 1, 2015, new iOS apps uploaded to the App Store must include 64-bit support and be built with the iOS 8 SDK, included in Xcode 6 or later. To enable 64-bit in your project, we recommend using the default Xcode build setting of “Standard architectures” to build a single binary with both 32-bit and 64-bit code." 需要将支持的体系结构切换为可用的ARM64组合之一(如上所示),重新编译并重新提交。You need to switch the supported architectures to one of the available ARM64 combination (as shown above), recompile and resubmit.

MacMac

重要

从2018年1月开始,提交到 Mac App Store 的所有新 Mac 应用都必须支持64位。Starting in January 2018, all new Mac apps submitted to the Mac App Store must support 64-bit. 现有的 Mac 应用商店应用及其更新必须支持64位(从6月 6 2018 日开始)。Existing Mac App Store apps and their updates must support 64-bit starting in June 2018. 请参阅Apple 的公告指南,其中介绍了如何将你的 Xamarin 应用程序更新到64位See Apple's announcment and a guide that describes how to update your Xamarin.Mac apps to 64-bit.

大多数新式 Mac 计算机都支持32位和64位的应用程序。Most modern Mac computers support both 32-bit and 64-bit applications. MacOS 10.6 (雪 Leopard)是在32位系统上运行的最后一个操作系统。MacOS 10.6 (Snow Leopard) was the last operating system to run on 32-bit systems. 自2010以来发布的大多数 Mac 都支持这两个系统。Most Macs released since 2010 support both systems.

与 iOS 不同,在最新版本的 macOS 中引入的许多新框架仅在64位模式下受支持(CloudKit、EventKit、GameController、Localauthentication.framework、MediaLibrary、MultipeerConnectivity、NotificationCenter、GLKit、SpriteKit、社交、以及其他 MapKit)。Unlike iOS, many of the new frameworks introduced in recent versions of macOS are only supported in 64-bit mode (CloudKit, EventKit, GameController, LocalAuthentication, MediaLibrary, MultipeerConnectivity, NotificationCenter, GLKit, SpriteKit, Social, and MapKit, among others).

Unified API 允许开发人员选择他们想要生成的应用程序类型:32位或64位。The Unified API allow developers to choose what kind of applications they want to produce: 32-bit or 64-bit.

32 位应用程序将在32位和64位 Mac 计算机上运行,其地址空间限制为32位,并要求所有库都为32位。32-bit applications will run on both 32-bit and 64-bit Mac computers, have an address space limited to 32 bits, and require that all libraries are 32 bits.

如果你有32位依赖64项(如果你想要下载较小的下载,或者如果迁移到64位,则没有性能优势),则通常会使用此模式。You will typically use this mode if you have 32-bit dependencies that do not run in 64-bit mode, if you want to have a smaller download, or if there are no performance benefits in moving to 64-bit.

此模式受到限制,因为你将无法使用 macOS Mavericks 和 macOS Yosemite 中提供的多个框架。This mode is limiting as you wont be able to use many frameworks available in macOS Mavericks and macOS Yosemite.

64 位应用程序将仅在64位 Mac 设备上运行。64-bit applications will only run on 64-bit Mac devices.

对于 Mac,这是首选的操作模式,因为目前使用的大多数 Mac 支持64位模式,并且你有权访问 Apple 提供的完整框架集。For Mac, this is the preferred mode of operation as most Macs in use today support 64-bit mode, and you have access to the complete set of frameworks provided by Apple.

启用 Xamarin Mac 应用的64位版本Enabling 64-bit builds of Xamarin.Mac apps

有关使用 Xamarin 生成64位应用的信息,请参阅将Xamarin 统一应用程序更新到64位指南。For information about building a 64-bit app using Xamarin.Mac, please see the Updating Xamarin.Mac Unified applications to 64-bit guide.