【问题标题】:SecItemAdd returns -50 on Xcode 9SecItemAdd 在 Xcode 9 上返回 -50
【发布时间】:2018-03-22 23:00:06
【问题描述】:

以下代码:

    var newItem = [String: Any]()

    newItem[kSecClass as String] = aValue
    newItem[kSecAttrService as String] = aValue
    newItem[kSecAttrAccount as String] = aValue
    newItem[kSecValueData as String] = aValue
    newItem[kSecAttrAccessible as String] = aValue

    // Add a the new item to the keychain.
    let status = SecItemAdd(newItem as CFDictionary, nil)

    if status != noErr {
        print("Error during access token save. \(status)")
    }

在 Xcode 8 上完美运行,不返回任何错误,并在 Xcode 9 上返回 -50 错误(又名。errSecParam)。

有什么帮助吗?

【问题讨论】:

    标签: ios swift security xcode8 xcode9


    【解决方案1】:

    我找到了答案。我需要为 Keychain 框架添加一个宿主应用程序以获得完整的上下文。

    在我的xxxxxTests 目标中,我必须在Host Application 菜单(在General 选项卡中)设置我的主应用程序。

    奇怪的是在 Xcode 8 上没有必要。

    【讨论】:

      猜你喜欢
      • 2016-11-22
      • 2013-12-19
      • 2013-09-08
      • 2018-09-05
      • 1970-01-01
      • 2018-03-04
      • 1970-01-01
      • 1970-01-01
      • 2017-11-07
      相关资源
      最近更新 更多