Hi,
Using Xamarin Studio on Mac OS X, I created a brand new Xamarin forms project and added the Esri.ArcGISRuntime.Xamarin.Forms and Esri.ArcGISRuntime.Xamarin.iOS packages (both v100.0.0) via NuGet. Created a simple Xaml page just like the sample:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
xmlns:mapping="clr-namespace:Esri.ArcGISRuntime.Mapping;assembly=Esri.ArcGISRuntime"
xmlns:local="clr-namespace:EsriTest"
x:Class="EsriTest.EsriTestPage">
<Grid>
<esriUI:MapView x:Name="MyMapView"/>
</Grid>
</ContentPage>
With the code behind:
public partial class EsriTestPage : ContentPage
{
public EsriTestPage ()
{
InitializeComponent ();
Initialize ();
}
private void Initialize ()
{
// Create new Map with basemap
Map myMap = new Map(Basemap.CreateImagery());
// Assign the map to the MapView
MyMapView.Map = myMap;
}
}
It compiles and deploys fine to an iPad Air device (iOS 10.1.1), but when I hit this page I get a System.MissingMethodException - Default constructor not found for type Esri.ArcGISRuntime.Xamarin.Forms.MapView:
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")]
private void InitializeComponent() {
this.LoadFromXaml(typeof(EsriTestPage)); // throws exception here
MyMapView = this.FindByName <global::Esri.ArcGISRuntime.Xamarin.Forms.MapView>("MyMapView");
}
Any help is appreciated... thanks.
Solved! Go to Solution.
Schuyler,
Try changing the following setting in the IOS project options (if not set already):
Set the Linker behavior on project options --> iOS Build to "Don't link"
Let me know if this resolves the error you are getting.
Tony Wakim
Schuyler,
Try changing the following setting in the IOS project options (if not set already):
Set the Linker behavior on project options --> iOS Build to "Don't link"
Let me know if this resolves the error you are getting.
Tony Wakim
Looks like that did the trick for iPhone/iPad. Thank you much!
Schuyler
Hi Schuyler,
I wanted to clear up what's going on here and what the available options for addressing it are. First, what the linker does is analyze the code in your app and discard anything that's not used - more info here. By default, it does not include XAML in what it looks at. In your case, the MapView class itself is only being referenced in XAML and not anywhere in your code. So the linker then thinks that nothing in the Esri.ArcGISRuntime.Xamarin.Forms assembly (which essentially just includes the Xamarin Forms MapView and SceneView) is being used, so it excludes this assembly from the final compiled app.
Setting the linker to "don't link" gets around the issue by opting out of linking entirely. This is fine for debug builds, but for release you wouldn't want to do this, as it opts out of the size reductions the linker can bring.
Alternatively, there are two ways to get around this while still letting the linker do it's thing:
Hope this helps.
-Rich
Awesome Rich. Thank you for the additional information and explanation.
Schuyler