You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xamarin Forms PCL项目能否集成Esri GIS SDK?新手技术咨询

Hey there! Let me walk you through this since I’ve worked with Xamarin Forms and Esri’s GIS SDKs before:

Answers to Your Esri SDK & Xamarin PCL Questions

Can I use the Esri GIS SDK in my PCL project?

Yes you can! Esri’s ArcGIS Runtime SDK for .NET provides a .NET Standard library that works seamlessly with Xamarin Forms PCL projects—as long as your PCL targets .NET Standard 2.0 or higher. Most modern Xamarin Forms PCLs are set up for this by default, but double-check your project’s target framework to be sure.

Do I have to switch to a Shared Project?

Nope, switching to a Shared Project isn’t required. The .NET Standard-based Esri SDK is designed to work with PCLs (or .NET Standard libraries) so you can keep your shared code in the PCL and only handle platform-specific setup in your iOS/Android projects. Shared Projects are an alternative approach, but they’re not a hard requirement here.

Are there separate Xamarin Esri SDKs for iOS and Android?

Absolutely! Esri provides platform-specific packages for both Xamarin.iOS and Xamarin.Android alongside the .NET Standard library. These platform packages handle native initialization, permissions, and any device-specific functionality that the shared .NET Standard library can’t cover on its own.


Step-by-Step Solution to Set This Up

Here’s how to get everything working smoothly:

  1. Verify your PCL’s target framework

    • Right-click your PCL project → Properties → Application
    • Make sure the target framework is set to .NET Standard 2.0 or higher (if it’s an older PCL Profile, you’ll want to upgrade it to .NET Standard—Esri no longer supports legacy PCL Profiles).
  2. Install the shared Esri package in your PCL

    • Use NuGet Package Manager to install Esri.ArcGISRuntime.Xamarin.Forms in your PCL project. This pulls in the .NET Standard library you’ll use for shared map logic.
  3. Set up the iOS project

    • Install Esri.ArcGISRuntime.Xamarin.iOS via NuGet in your iOS project.
    • In AppDelegate.cs, add this line to the FinishedLaunching method to initialize the SDK:
      Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.Initialize();
      
    • Don’t forget to add required permissions to Info.plist (e.g., location access for maps: add NSLocationWhenInUseUsageDescription with a description of why you need location access).
  4. Set up the Android project

    • Install Esri.ArcGISRuntime.Xamarin.Android via NuGet in your Android project.
    • In MainActivity.cs, add this line to the OnCreate method to initialize the SDK:
      Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.Initialize();
      
    • Add necessary permissions to AndroidManifest.xml, like:
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
      
  5. Use Esri controls in your PCL Xamarin.Forms code

    • Here’s a quick example of adding a map to your main page:
      using Esri.ArcGISRuntime.Mapping;
      using Esri.ArcGISRuntime.Xamarin.Forms;
      
      namespace YourAppNamespace
      {
          public partial class MainPage : ContentPage
          {
              public MainPage()
              {
                  InitializeComponent();
      
                  // Create a map view and a base map
                  var mapView = new MapView();
                  var baseMap = new Map(BasemapStyle.ArcGISStreets);
                  mapView.Map = baseMap;
      
                  // Add the map view to your page
                  Content = mapView;
              }
          }
      }
      

Quick Note

Make sure your Xamarin.Forms version is compatible with the Esri SDK version you install—stick to the latest stable releases of both to avoid compatibility issues.

内容的提问来源于stack exchange,提问作者PritiPriri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:18:55