无法在 PCL iOS 项目中安装 Xamarin.Mobile

Could not install Xamarin.Mobile in PCL iOS Project

我正在尝试通过 NuGet 在 PCL iOS 项目中安装 Xamarin.Mobile,但出现此错误!

Could not install package 'xamstore-xamarin.mobile 0.7.1'. You are trying to install this package into a project that targets 'Xamarin.iOS,Version=v1.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

这是我的 AppDelegate

// The UIApplicationDelegate for the application. This class is responsible for launching the 
// User Interface of the application, as well as listening (and optionally responding) to 
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
    //
    // This method is invoked when the application has loaded and is ready to run. In this 
    // method you should instantiate the window, load the UI into it and then make the window
    // visible.
    //
    // You have 17 seconds to return from this method, or iOS will terminate your application.
    //
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        global::Xamarin.Forms.Forms.Init();
        Xamarin.FormsMaps.Init();
        LoadApplication(new App());

        return base.FinishedLaunching(app, options);
    }
}

我的SDK版本是10.1。

Xamarin.Mobile 在 Android 项目中工作正常。

知道如何解决这个问题吗?

使用 Microsoft 解决问题。

清理您的解决方案并再次重建。

Xamarin.Mobile NuGet 包与 PCL 不兼容,因此出现错误。此 DLL 旨在安装到 iOS/Android/Windows 应用程序项目中。没有跨平台 API 供 PCL 使用。

您可以将其与共享库一起使用。或者,您需要在每个平台项目中工作。

您可以尝试将 Xamarin.Mobile 作为组件添加,而不是使用 NuGet 添加 Xamarin.Mobile 的包。

右键单击组件文件夹:

在 Xamarin 组件上搜索和 select Xamarin.Mobile window:

可能有用!