Version: 2017.2
iOS 2D 纹理覆盖
Unity Remote

Upgrading to 64 bit iOS

iOS 64 bit support is implemented with the scripting backend called IL2CPP. It runs with your C#/UnityScript code.

IL2CPP 运行时将提前编译器与虚拟机相结合,将程序集转换为 C++,同时利用标准平台 C++ 编译器生成本机二进制文件。最终结果是显著改善性能、平台兼容性和可维护性。

IL2CPP is the only scripting backend to support deploying to ARM 64-bit on iOS, and is thus mandatory to deploy to the Apple app-store for releasing new apps.

To read more about IL2CPP see the blogposts The future of scripting in Unity, and Apple iOS 64-bit support in Unity.

如何在 iOS 上开始使用 IL2CPP

Pick it in Scripting Backend dropdown in Player Settings.

选择脚本后端 (Scripting Backend)
选择脚本后端 (Scripting Backend)

By default it will build for Universal architecture (including both ARM64 and ARMv7), if needed you might switch to specific architecture in Player Settings. There is number of things that should be done before your application is up and running in 64 bits:

  • You need 64 bit capable device to test on. These are all iOS devices with A7 or later chip (currently these are: iPhone 5S, iPad Air, iPad Mini Retina, iPhone 6, iPhone 6 Plus, iPad Mini 3, iPad Air 2).
  • You need all your native plugins to be compiled with 64 bit support (or be provided as source code). If you are using 3rd party plugin, you should contact your plugin vendor to obtain 64 bit capable and IL2CPP compatible version of that plugin. At the moment all latest Prime31 plugins are known to be good.
  • 如果您是插件供应商或者拥有自己的原生插件,则需要注意以下几点:
    • IL2CPP is not API-compatible (which is unexposed) with the Mono Runtime API, which means if plugin is using mono_* functions won’t link anymore. The best way to resolve this issue is to switch to managed delegate/callback approach and pass your managed callbacks to the native side of plugin and call them back from there when some native data or event arrives.
    • 所有作为预编译静态库(.a 文件)提供的插件现在都应该包含 ARM64 切片。
    • When doing native code/type conversion keep in mind that pointers and longs are now 64 bit wide and ints are still 32 wide.
  • To minimise generated amount of C++ code IL2CPP is always (even when Stripping level is set to Disabled) doing some sort of managed code stripping. Sometimes you will need to help it. Look for link.xml guide in iOS player size optimization manual.

故障排除

  • Q: My code is running slower on IL2CPP than on Mono. Why?
    A: Make sure you are testing your code performance in Xcode Release configuration. If issue still remains, please submit a bugreport!
  • Q: Unity generated Xcode project fails to compile with following or similar error: Method not found: 'Default constructor not found...ctor() of System.ComponentModel.Int64Converter'.
    A: Deserializers and serializers often reference some types only via .NET Reflection API and in such cases these methods or even classes might be stripped from project. You can hint managed code stripper that specific class / method is used either via link.xml or via introduction of dummy code that explicitly references it in one of your scripts.
  • Q: Unity generated Xcode project fails to compile with some other error.
    A: Please verify if all your plugins support ARM64 and IL2CPP and if that’s the case please submit a bug report and attach your project (or just scripting part of it) to the bug report. Thanks!
iOS 2D 纹理覆盖
Unity Remote