When i build my app directly to my iPhone i can store items in the keyChain but if i archive it and send it to to ItunesConnect and someone download it using testFlight it doesn't store the item in the keyChain
Here is the log of when he tries to access the 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))
EDIT
This is what i use to put something in the keychain: https://github.com/jrendel/KeychainWrapper/blob/master/KeychainWrapper/KeychainWrapper.swift
i don't know if it uses kSecClassGenericPassword. This is what i do to put the info in the keychain:
KeychainWrapper.setString(self.username.text, forKey: "username")
KeychainWrapper.setString(self.password.text, forKey: "password")
And i get it back using:
if let u = KeychainWrapper.stringForKey("username") {
username = KeychainWrapper.stringForKey("username")!
password = KeychainWrapper.stringForKey("password")!
}