【问题标题】:Crashing at AccountStore.Create ().Save (e.Account, ");在 AccountStore.Create ().Save (e.Account, ") 处崩溃;
【发布时间】:2017-04-24 16:02:00
【问题描述】:

在 Xamarin.Forms 示例 ToDoAwsAuth 中

https://developer.xamarin.com/guides/xamarin-forms/web-services/authentication/oauth/

成功登录后,在 OnAuthenticationCompleted 事件中,应用程序在尝试保存到 Xamarin.Auth 时崩溃

AccountStore.Create ().Save (e.Account, "ToDoList");

错误说不能对钥匙串说

期待帮助。

【问题讨论】:

  • 嘿,OP,如果你还活着,实际的错误信息是什么? not able to say to keychain 是什么意思。

标签: xamarin xamarin.ios


【解决方案1】:

查看您是否有一个名为 Entitlements.plist 的文件,如果有,请单击它并选中 Enable Keychain

使用以下内容创建一个新文件名Entitlements.plist,然后将其拖放到您的项目中

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>keychain-access-groups</key>
    <array>
        <string>your bundle id</string>
    </array>
</dict>
</plist>
  • 右键单击您的项目

  • 选择选项

  • 选择 iOS 捆绑签名

  • 选择Entitlements.plist

就是这样,应该没问题!

【讨论】:

  • 确保选择 iPhone 模拟器。对我来说,它会在 VS2017 中的 Active 配置下显示 Entitlements.plist,但如果您明确选择 Simulator,则不会。
【解决方案2】:

看起来这是 Xamarin.Auth 中的一个错误

https://github.com/xamarin/Xamarin.Auth/issues/128

【讨论】:

  • 不仅 - 在 iOS 返回的同一代码下还有几个问题。 - iOS10 模拟器的问题和 - Xamarin.Auth 中的错误,如果屏幕被锁定,则会阻止存储
【解决方案3】:

只需将空的 Entitlements.plist 添加到您的 iOS 应用项目即可。

Select(iOS App Project) /+ File /+ New File /+ iOS /+ Entitlements.plist

注意:这似乎是 Xamarin.Auth 中的一个错误和 Apple 在 iOS 10 SDK 中更改的结果(一些报告了模拟器中的错误)。

Xamarin.Auth 修复将在接下来的几个小时内(CI 服务器)在 nuget 版本 1.3.3-alpha-01 中发布

如果在锁定屏幕时执行身份验证,可能会发生类似错误(Xamarin.Auth 中的错误)。公关 80

相关:

https://github.com/xamarin/Xamarin.Auth/issues/128
https://bugzilla.xamarin.com/show_bug.cgi?id=43514

https://github.com/xamarin/Xamarin.Auth/pull/80

【讨论】: