以下代码:
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
)。
有什么帮助吗?
最佳答案
我找到了答案。我需要为 Keychain 框架添加一个主机应用程序以获得完整的上下文。
在我的 xxxxxTests
目标中,我必须在 Host Application
菜单(在 General
选项卡中)中设置我的主应用程序。
奇怪的是在 Xcode 8 上没有必要。
关于ios - SecItemAdd 在 Xcode 9 上返回 -50,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46685333/