Apple is requiring all apps submitted after February 1st, 2015 to include a 64-bit binary. As a library creator, your developers will need to have access to 64-bit versions of your libraries before this deadline so that they can update their apps.

The new Unified API that we introduced for both Mac and iOS not only allows you to improve code sharing between the two platforms, but it also enables you to create 64-bit compatible libraries for your developers.

We introduced two new target frameworks for Unified API projects: Xamarin.iOS and Xamarin.Mac. Support for these new frameworks has been added to NuGet 2.8.3 which was released last month.

Xamarin iOS, Mac and NuGet

With these new Unified frameworks now being recognized by NuGet, you can create a NuGet package that targets the Unified iOS and Unified Mac frameworks. We have also created a set of Portable Class Library (PCL) profiles for the Unified frameworks which allow you to add NuGet packages that have compatible Portable Class Libraries, such as Json.NET, into your Unified projects.

Now, let’s take a look at what software you need to be able to add NuGet packages to Unified projects and how to create a NuGet package that supports Unified project.

Getting Ready to Use NuGet Packages with Unified Projects

In order to fully support adding NuGet packages to Unified projects, you will need to use NuGet 2.8.3 or above and have the Xamarin Portable Profiles for Unified installed. Additionally, you will need the latest Beta releases with the finalized Unified API when creating 64-bit libraries.

Software needed on Windows

The simplest way to upgrade NuGet inside Visual Studio is to use the extension manager:

  • Select Extensions and Updates from the Tools menu.
  • In the Extensions and Updates dialog, select the Updates tab and then select Visual Studio Gallery.
  • If NuGet Package Manager for Visual Studio is listed as an update, then select it and click the Update button.

Extensions and Updates Dialog NuGet Update

Software needed on Mac

  • Xamarin Studio 5.7 or above.
  • Mono 3.12 or above.
  • Xamarin.iOS 8.6

Creating a NuGet Package for Unified Projects

A NuGet package can be installed into different project types that target different frameworks if it contains files for those frameworks. The NuGet package indicates it supports a particular target framework by containing directories named after that framework. In each of these directories, the NuGet package will contain your files that are specific for that target framework.

To have your NuGet package explicitly target Xamarin.iOS and Xamarin.Mac your .nuspec file should contain a section similar to the one shown below below:

The target directory is the important part and should be specified as shown above. The src attribute points to the assemblies that should be used with that particular target framework. The created NuGet package should have a directory structure that looks like the following:

NuGet Unified Lib Directories

When you install the above NuGet package into a Unified iOS project the assembly from the lib\Xamarin.iOS10 directory will be added as a reference. For a Unified Mac project, the assembly from the lib\Xamarin.Mac20 directory will be referenced.

For NuGet packages that contain Portable Class Libraries, the recommended approach is to not include Xamarin.iOS nor Xamarin.Mac in the lib directory name. This can happen if you are using NuGet.exe pack passing the project file as a command line argument on a machine that has the Xamarin Unified profiles installed.

The following PCL lib directory follows the recommendation:


Whilst the following PCL lib directory should be avoided:


The reason for this is to ensure your NuGet package can be installed into projects on machines that do not have the Xamarin Unified PCL profiles installed or do not have a version of the NuGet Package Manager installed that has support for the Unified frameworks.

Here are a few example NuGet packages that include assemblies that explicitly target Xamarin Unified projects:

  • ModernHttpClient – Write your app using System.Net.Http, but drop this library in and it will go drastically faster.
  • Splat – A library to make things cross-platform that should be.
  • Xamarin.Forms – Build native UIs for iOS, Android, and Windows Phone from a single, shared C# codebase.

Learn More

If you would like to learn more about the Unified API and NuGet here are some resources: