为 iOS Xamarin 表单执行远程构建时出现 Prism Navigation 错误

Prism Navigation error while performing remote build for iOS Xamarin forms

我已将我的 visual studio 与虚拟 MAC 机器配对,创建了所需的钥匙串,并将其添加到我的项目中。我不断收到此错误:

Prism.Navigation.NavigationException: An error occurred while resolving the page. This is most likely the result of invalid XAML or other type initialization exception --->
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: 
Exception has been thrown by the target of an invocation. ---> Microsoft.Identity.Client.MsalClientException: The application cannot access the iOS keychain for the application publisher (the TeamId is null). This is needed to enable Single Sign-On between applications of the same publisher.

我也试过禁用 Entitlements.plist 中的钥匙串 - 没用。不知何故,这似乎是一个 Prism 导航问题,因为当我消除它并简单地导航到一个示例页面时,它就起作用了。

我还尝试了 运行 我在物理 Mac 上的项目,我得到了这个:

2020-06-01 01:45:29.879475-0700 NatWest.KeepSafe.MobileApp.iOS[6277:128192] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=6277
2020-06-01 01:45:29.880109-0700 NatWest.KeepSafe.MobileApp.iOS[6277:128192] SecTaskCopyDebugDescription: NatWest.KeepSafe[6277]/0#-1 LF=0
2020-06-01 01:45:29.897634-0700 NatWest.KeepSafe.MobileApp.iOS[6277:128192] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=6277
2020-06-01 01:45:29.897992-0700 NatWest.KeepSafe.MobileApp.iOS[6277:128192] SecTaskCopyDebugDescription: NatWest.KeepSafe[6277]/0#-1 LF=0

P.S:代码在物理 iPhone 上完美运行,但在模拟器 运行 上出现问题。

这与 Prism 完全无关。MSAL 实际上与 Pr​​ism 一起工作得很好你可以看到 AP.AzureADAuth 模块示例。

您发布的错误实际上告诉您问题所在。您的权利有问题,无法在 iOS 模拟器上使用 运行。

有关更多信息,您需要查看此处的文档:

var builder = PublicClientApplicationBuilder
     .Create(ClientId)
     .WithIosKeychainSecurityGroup("com.microsoft.adalcache")
     .Build();

并且在您的 Entitlements.plist 中,您需要更新为:

<dict>
  <key>keychain-access-groups</key>
  <array>
    <string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
  </array>
</dict>