2017-10-11 106 views
0

返回-50以下代码:SecItemAdd上的Xcode 9

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。)

任何帮助?

回答

0

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

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

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