iOS 64-Bit Migration
As Apple announced on October 20, 2014:
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.
What does this mean for you Vuforia developers?
As of February 1st 2015, newly released apps will need to take advantage of the iOS 8 SDK and the new 64-bit ARM chips in newer iOS devices.
Vuforia SDK 4.0 fully supports iOS 8 and 64-bit ARM architecture, and the Vuforia iOS samples have also been updated to correctly build and run in 64-bit mode.
In particular, the newly released Vuforia Sample projects already come with the correct Xcode Build Settings to support both the 32-bit (armv7, armv7s) and the 64-bit (arm64) modes.
You can obtain the Vuforia 4.0 SDK and samples with iOS 64bit support in the downloads section of the Developer Portal.
If you are creating an app using Vuforia and iOS 8, you should also make sure to apply the same build settings to your own project, in order to be able to upload your App to the Apple App Store. There are instructions for configuring Unity iOS 64bit builds at the end of this article.
It is also recommended that you test your App on both at least one 64-bit and one 32-bit device, before submitting it to the App store; for example, the iPhone 5S is equipped with 64-bit CPU, whereas the iPhone 4S has a 32-bit chip. An App must be able to correctly run on both platforms (32 and 64-bit).
Do I need to build two distinct apps?
You do not need to build two distinct apps, i.e. one App in 32-bit mode and another in 64-bit mode. Simply build your Xcode project with the recommended Build Settings, which include both the armv7/armv7s (32-bit) and the arm64 architectures; this will ensure that your App will be packaged with all the necessary artifacts to be able to run on both 32-bit and 64-bit devices.
When writing an iOS App with the Vuforia SDK targeting the 64-bit architecture, you should generally follow the same general guidelines that apply to any iOS App. Vuforia does not introduces any additional requirements or constraints.
Two Conventions: ILP32 and LP64
The 32-bit runtime uses a convention called ILP32, in which integers, long integers, and pointers are 32-bit quantities. The 64-bit runtime uses the LP64 convention; integers are 32-bit quantities, and long integers and pointers are 64-bit quantities.
One of the most important and obvious recommendations stemming from the above is to avoid casting pointers to integers. If your app code does cast pointers to integers, your code may behave correctly in 32-bit mode but it may result in a crash or other runtime misbehavior when executed in 64-bit mode, as soon as a pointer exceeds the 32-bit scope.
Also, an array containing elements of type long will be double its size in bytes when the code is built in 64-bit mode, with respect to the 32-bit case. For large data arrays this may also result in a significantly increased memory usage. Keep this in mind when creating large arrays and choose the appropriate type; in many cases, 32-bit integers may be sufficient to represent common data values.
NSInteger data type:
The NSInteger type is a 32-bit integer in the 32-bit runtime and a 64-bit integer in the 64-bit runtime. When receiving an NSInteger data from a method or code expression, you should use the NSInteger type to hold the result; for example, casting an NSInteger to an int might result in truncation of the original value (data loss) when in 64-bit mode, so in general this should be avoided, unless the value in question is known / guaranteed to always be within 32-bit boundaries.
CGFloat data type:
CGFloat changes size in 64-bit code. The CGFloat type changes to a 64-bit floating point number. As with the NSInteger type, you cannot assume that CGFloat is a float or a double. So use CGFloat consistently.
For a complete guide on 64-bit transition, please refer to the official iOS 64-bit migration guidelines published in the Apple website:
Follow these instructions to ensure you build with Unity iOS 64bit support
- Use the latest Unity release *
- Select the iOS build target in Build Settings.
- In Other Settings , set the Scripting Backend to IL2CPP
- The Architecture setting must be set to Universa
Note: Unity 64bit support was original introduced in the Unity 4.6.1p5 patch release. This is the earliest version that can support the Vuforia iOS 64bit Unity extension.