iosxamarin.forms.net-standard-2.0arcgis-runtimearcgis-runtime-net

"MapView not found in Esri.ArcGISRuntime.Xamarin.Forms" error Xamarin Forms iOS


I am using ArcGIS Runtime 100.4.0 in my Xamarin forms solution which is consist of

My code is very simple and it only tries to display a map. I used the code from Esri example for displaying a map and I already have it working in another project where the app logic is in a Visual Studio Shared Project (instead of .net standard). The Esri sample project also uses Visual Studio Shared Project. I think the issue that I am facing can be resolved by using Visual Studio Shared Project but for some technical reasons I have to use .Net Standard for my shared logic.
Now here is the issue:
The android app shows the map without an issue, however in my iOS app, I get the following error in my .net standard project when the app tries to initialize the map:

MapView not found in xmlns clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms

I am confident that I have all right references in my iOS project and also the fact is the error happens in the .net standard project which is working in my Android app.
How is it possible to be missing MapView class when using my .netstandard project in iOS but not android?


Solution

  • While I was investigating this I found a solution which I have no clue about the reason:
    I added a line before InitializeComponent() in my page code behind which simply creates an instance of Esri.ArcGISRuntime.Xamarin.Forms.MapView, and that fixed it:

        public MapPage()
        {
            var a = new Esri.ArcGISRuntime.Xamarin.Forms.MapView();
            InitializeComponent();
        }
    

    If I remove that line I get the error again in iOS. I have no idea why that happens