Tips for Xuni Deployment and Debugging issues in Xamarin.Forms
From time to time issues might crop up when you're ready to either debug or deploy your Xamarin.Forms app. The Xamarin toolset can sometimes make this more complicated for a developer since there's multiple IDE's you can work with, different native APIs and conventions to consider, and a lot of different tools involved. In this article, we'll go through some common issues that can come up in Xuni deployment, and provide some solutions for these common cases.
ERROR: Could not AOT the Assembly on iOS
This frustrating bug can crop up when debugging a Xamarin.Forms app on iOS devices. Though the error is quite opaque, the solution is relatively easy. All you need to do is navigate to the project properties for you iOS project and disable incremental builds. There are many different permission on both iOS and Android so it pays to double check when trying to use a new API or piece of hardware for a corresponding permission.
Setting the right permissions
This is a relatively broad category, but important for every type of device. Android and iOS both have their own set of permission necessary for interacting with the onboard hardware, and it's important that you follow the conventions for each OS. Interacting with the filesystem, notifications, camera, and other pieces of hardware and services all require that you specially ask for these app permissions. This means mentioning the correct permissions in your info.plist on iOS or AndroidManifest.xml on Android, as well as checking whether the user grants you permission to use that function in code.
Controls don't display when deployed on an iOS device in release mode
Another issue that can occur on iOS stems from the relationship between linking and renderers on iOS devices. When your app is deployed in release mode to an iOS device, Xamarin's linker will try to trim any code it believes is unnecessary for deployment unless you've explicitly set it to not link in your project settings. Usually you want to avoid this since it will increase the size of your deployed app. You can still use the option to "Link Framework SDKs only", but you can fully avoid this problem provided you follow these steps. The iOS renderer needs to be initialized in the AppDelegate portion of your iOS project. Generally, you'll do this by adding a line like this: Xuni.Forms.Calendar.Platform.iOS.Forms.Init();
In the instance that your controls don't show up when deployed to a device, you'll need to add an additional line: public static Xuni.Forms.Calendar.Platform.iOS.CalendarRenderer calDummy;
This will force the linker to include the FlexChart renderer, and ensure that it is visible when deployed. The full list of possibilities is below: public static Xuni.Forms.FlexChart.Platform.iOS.FlexChartRenderer chartDummy; public static Xuni.Forms.FlexGrid.Platform.iOS.FlexGridRenderer gridDummy; public static Xuni.Forms.Gauge.Platform.iOS.LinearGaugeRenderer lgDummy; public static Xuni.Forms.Gauge.Platform.iOS.RadialGaugeRenderer rgDummy; public static Xuni.Forms.Gauge.Platform.iOS.BulletGraphRenderer bgDummy; public static Xuni.Forms.FlexPie.Platform.iOS.FlexPieRenderer pieDummy; public static Xuni.Forms.Calendar.Platform.iOS.CalendarRenderer calDummy; public static Xuni.Forms.Input.Platform.iOS.AutoCompleteRenderer acDummy; public static Xuni.Forms.Input.Platform.iOS.ComboBoxRenderer cbDummy; public static Xuni.Forms.Input.Platform.iOS.DropDownBaseRenderer ddDummy; public static Xuni.Forms.Input.Platform.iOS.MaskedTextFieldRenderer mtfDummy; public static Xuni.Forms.Core.Platform.iOS.XuniCheckBoxRenderer xcbDummy;
Xuni Deployment
There are always issues that can crop up when you're ready to deploy your application so we wanted to cover some of the common cases that can crop up. These cases don't always crop up, but when they do they can be difficult to diagnose. Hopefully this eases any difficulty that can crop up with Xuni deployment.