当我直接将我的应用程序构建到我的iPhone时,我可以将项目存储在keyChain中,但如果我将其存档并将其发送到ItunesConnect并且有人使用testFlight下载它,则不会将该项目存储在keyChain中
以下是他尝试访问钥匙串的日志:
Dec 4 23:10:40 <Error>: securityd_xpc_dictionary_handler appName[2687] add The operation couldn’t be completed. (OSStatus error -25299 - duplicate item O,genp,7937CF51,L,ak,bundleID.appName,0,acct,svce,gena,v_Data,20141205041040.123944Z,F87F1109)
Dec 4 23:10:40 <Error>: SecOSStatusWith error:[-25299] The operation couldn’t be completed. (OSStatus error -25299 - Remote error : The operation couldn‚Äôt be completed. (OSStatus error -25299 - duplicate item O,genp,7937CF51,L,ak,bundleID.appName,0,acct,svce,gena,v_Data,20141205041040.123944Z,F87F1109))
Dec 4 23:10:40 <Error>: securityd_xpc_dictionary_handler appName[2687] add The operation couldn’t be completed. (OSStatus error -25299 - duplicate item O,genp,801FEEB1,L,ak,bundleID.appName,0,acct,svce,gena,v_Data,20141205041040.146946Z,5CD00596)
Dec 4 23:10:40 <Error>: SecOSStatusWith error:[-25299] The operation couldn’t be completed. (OSStatus error -25299 - Remote error : The operation couldn‚Äôt be completed. (OSStatus error -25299 - duplicate item O,genp,801FEEB1,L,ak,bundleID.appName,0,acct,svce,gena,v_Data,20141205041040.146946Z,5CD00596))
Dec 4 23:10:40 <Error>: securityd_xpc_dictionary_handler appName[2687] add The operation couldn’t be completed. (OSStatus error -25299 - duplicate item O,genp,7937CF51,L,ak,bundleID.appName,0,acct,svce,gena,v_Data,20141205041040.20269Z,846CAAC0)
Dec 4 23:10:40 <Error>: SecOSStatusWith error:[-25299] The operation couldn’t be completed. (OSStatus error -25299 - Remote error : The operation couldn‚Äôt be completed. (OSStatus error -25299 - duplicate item O,genp,7937CF51,L,ak,bundleID.appName,0,acct,svce,gena,v_Data,20141205041040.20269Z,846CAAC0))
Dec 4 23:10:40 <Error>: securityd_xpc_dictionary_handler appName[2687] add The operation couldn’t be completed. (OSStatus error -25299 - duplicate item O,genp,801FEEB1,L,ak,bundleID.appName,0,acct,svce,gena,v_Data,20141205041040.222921Z,7E11CA46)
Dec 4 23:10:40 <Error>: SecOSStatusWith error:[-25299] The operation couldn’t be completed. (OSStatus error -25299 - Remote error : The operation couldn‚Äôt be completed. (OSStatus error -25299 - duplicate item O,genp,801FEEB1,L,ak,bundleID.appName,0,acct,svce,gena,v_Data,20141205041040.222921Z,7E11CA46))
修改
这就是我用来在钥匙串中放置东西的内容:https://github.com/jrendel/KeychainWrapper/blob/master/KeychainWrapper/KeychainWrapper.swift
我不知道它是否使用kSecClassGenericPassword。这就是我将信息放入钥匙串的方法:
KeychainWrapper.setString(self.username.text, forKey: "username")
KeychainWrapper.setString(self.password.text, forKey: "password")
我用它来取回它:
if let u = KeychainWrapper.stringForKey("username") {
username = KeychainWrapper.stringForKey("username")!
password = KeychainWrapper.stringForKey("password")!
}
答案 0 :(得分:1)
您应检查设备上无法访问钥匙串的控制台,并查找指示钥匙串访问问题的日志。这听起来像权利问题。查看此常见问题解答,了解如何解决您可能在控制台中看到的问题:
https://developer.apple.com/library/ios/qa/qa1726/_index.html
修改强>
我认为您可能没有填写钥匙串项目的所有必要信息。如果您使用的是kSecClassGenericPassword
,那么您需要同时填写kSecAttrAccount
和kSecAttrService
此博客文章包含更多详细信息: http://useyourloaf.com/blog/2010/04/28/keychain-duplicate-item-when-adding-password.html
此StackOverflow问题列出了构成主键的组合:What makes a keychain item unique (in iOS)?
对于同样的问题,这是另一个问题:Error saving in the keychain with iphone sdk
答案 1 :(得分:1)
这似乎是Swift编译器的一个错误。
如果您在目标的“构建设置”中将“发布”的“优化级别”更改为“无”,则该工作
在此主题中通过Mark检查答案:https://stackoverflow.com/a/26467942/2977842
希望这有帮助!