Microsoft has announced it will end support for Xamarin and Xamarin.Forms on May 1, 2024. The Xamarin.Android and Xamarin.iOS platforms are now integrated directly into .NET. 


Starting with CoPilot 10.27, Trimble Maps has updated its CPIK libraries and sample applications for .NET Android and .NET iOS. We recommend all current Xamarin implementations transition to .NET, as technical support for Xamarin versions of CoPilot ends on March 31, 2024


If you are upgrading your application from Xamarin to .NET, follow the steps below to integrate the .NET CPIK libraries for CoPilot 10.27 and higher. Upgrading from Xamarin to .NET will not require changes to any of the source code. You just need to upgrade the project target framework.


The basic steps are:

  1. Install a new version of Visual Studio Code (2022), if you haven't already. CoPilot targets .NET version 8.0, which is not supported by Visual Studio 2019.
  2. Create a .NET application for CoPilot.
  3. Copy the source code from the existing Xamarin app, using the .NET dependencies.
  4. Integrate the latest version (10.27 and higher) of CPIK libraries.


How To Integrate CPIK into your .NET Application


Differences between Xamarin and .NET integrations

The main differences between installing CoPilot CPIK using Xamarin and using .NET are described below.


Upgrading a Xamarin.Android application to .NET

(The example below uses the CPIKFragmentApp, our demo application, as a template to demonstrate how to transition to .NET)


When you open your Xamarin application, the left image below is how the Visual Studio Solution Explorer tool window appears. To the right is how it appears after an upgrade to .NET.



The differences between Xamarin and .NET:

  1. Instead of References in Xamarin, we now have Dependencies in .NET and in the dependencies are split by Frameworks, Analyzers, Packages, and Projects. 
  2. The project CPIK_JavaBindings is an Android Java Bindings Library instead of an Android Bindings Library (Xamarin). This new project targets .NET 8.0 instead of MonoAndroid (Xamarin). 
  3. The project FragmentApp is an Android Application instead of a Mobile App (Xamarin) that also targets the .NET 8.0 framework instead of MonoAndroid (Xamarin). 


The difference between the CPIK_JavaBindings in the old Xamarin and new .NET:

  • The new .NET CPIKWrapper.dll NO LONGER embeds the cpiklibraryaar like the Xamarin CPIKWrapper.dll did. (Go here if you would like to learn more about why this happens.) Since we no longer embed the cpiklibraryaar-release.aar in the CPIKWrapper.dll, we will need to add it manually to our application and set the build action to "Embed Resource."


To add a NuGet package:

  1. Right-click Dependencies and select Managed NuGet packages
  2. In the project file (.csproj), they appear as <PackageReference/> instead of <Reference/> and the syntax for that tag is more simplified. The .NET Android Application also doesn't need a Resource.designer.cs. They are auto generated in the code generation step. 
  3. Similar to the Resource.designer.cs, the AssemblyInfo.cs file is automatically generated based on project settings. These files are both deleted from the Properties folder.


Upgrading a Xamarin.iOS application to .NET

(The example below uses the CPIKFragmentApp, our demo application, as a template to demonstrate how to transition to .NET)


The Xamarin.iOS to .NET iOS upgrade is similar to Android (above). We now use the .NET 8.0 workload and build the iOS Binding differently. On the right, below, is the new project solution for .NET in Visual Studio 2022 with a more organized structure to the Dependencies.



The CPIKBinding.dll Binding Library used with .NET does not embed the CoPilotIntegrationKit.framework, similar to how the Android CPIKWrapper.dll does not embed the Android archive cpiklibraryaar

  • Therefore, when referencing the CPIKBinding.dll assembly, you will need to reference the CoPilotIntegrationKit.framework alongside it as a "Native Reference". 
  • If you are using a CPIKBinding project alongside your iOS application, then you do not have to add the CoPilotIntegrationKit.framework as the CPIKBinding Binding Library project references it. Whichever manual method you choose to use, make sure the CoPilotIntegrationKit.framework is used somewhere.