Earlier this month we announced that Xamarin.iOS 8.6, featuring the Unified API, is available in the stable channel. This release comes perfectly timed for Apple’s February 1st deadline for new iOS app submissions and June 1st deadline for all new and existing iOS app submissions or updates to include 64-bit support.
In this webinar recording, Xamarin Evangelist Mike James provides an overview on how to make sure your libraries and apps are 64-bit ready by Apple’s deadlines, including how to migrate apps to the Unified API. In addition to the Q&A at the end of the video, we have also included an extended Q&A, below, covering more of the many questions asked during the webinar.
The sample used in the demo can be found here.
Do we need 64-bit versions of portable libraries coming as NuGet packages to use in a ‘unified’ project?
Library creators will need to update to the new Unified API, and we’ve got some excellent documentation about this here.
Why does the compiler not decide to use int or nint for us? This does not seem to be very “.NET like”.
In a 32-bit world, NSInteger could very easily be mapped to the System.Int32 (short: int) and it worked very well. With NSInteger now being both 32-bit and 64-bit (depending on the underlying architecture of the platform), this approach no longer works.
We’ve gone through all of our iOS and Mac API’s and found every instance of the Objective-C API using NSInteger that originally was mapped to int and these now take an nint.
You can learn more about our decisions behind nint here.
What is a Type Registrar?
On startup, Xamarin.iOS will registered managed classes (which include the [Register] attribute) and methods (which include the [Export] attribute) with the Objective-C runtime. This allows managed classes to be created and managed methods to be called from Objective-C. This is how methods and properties are linked between the C# and Objective-C worlds.
You can learn more here.
How should we handle the new “n” types in shared code?
The new native types found in the Unified API should only be shared in iOS and Mac projects. When creating libraries for consumption outside of these platforms (PCL, Share libraries, etc.) you should be using Int for 32-bit values and Long for 64-bit values.
Learn more about the new type here.
So with non-64-bit devices, will we have to do something different or will it just work?
When you build your Unified API based app, it will by default build dual 32/64-bit binaries transparently.
You alluded to new garbage collection; please elaborate.
We now have a garbage collector called sgen, which is now the default (as opposed to Boehm) which was used for the Classic iOS apps. We’ve also shipped support for our new reference counting system, which helps solves a number of problems that caused apps to crash. Another benefit of the change means your app consumes less memory. (The new reference counting can also be enabled in the Classic API from the project settings)
Learn more here.
Should I migrate my UI shared project on Xamarin.Forms? Or just the iOS Project?
You will only need to update the iOS project rather than the shared project. You can find our documentation on Xamarin.Forms migration here.
What about migration of an existing Plugin for Xamarin.Forms? How do we keep compatibility with existing apps that might be using our control and also provide the 64-bit support?