I'm seeing the same thing, when I start a new app from a template:
2022-11-14 16:08:34.408009+0100 KeychainTest[23016:1864774] OSStatus error: [-34018] Security error has occurred.
2022-11-14 16:08:34.408167+0100 KeychainTest[23016:1864774] OSStatus error: [-34018] Security error has occurred.
No string returned
My test code was like:
let keychain = UICKeyChainStore.init(service: "de.NAME.APP", accessGroup: "group.de.NAME.APP")
keychain.setString("ABC", forKey: "MyKey")
let testString = keychain.string(forKey: "MyKey")
if let testString = testString {
print("Returned string: " + testString)
} else {
print("No string returned")
}
(using this lib: https://github.com/kishikawakatsumi/UICKeyChainStore)
To rule out any problem with the lib, I tried the code found at https://stackoverflow.com/a/42360846:
let test = "ABC"
let data = test.data(using: .utf8)
if let data = data {
KeyChain.save(key: "MyKey", data: data)
let keyChainData = KeyChain.load(key: "MyKey")
if keyChainData != nil {
print("Data was returned")
} else {
print("No data returned")
}
}
Same error, with this one, so basically the app logs
2022-11-14 16:24:18.381452+0100 KeychainTest[24118:1904070] OSStatus error: [-34018] Security error has occurred.
2022-11-14 16:24:18.381605+0100 KeychainTest[24118:1904070] OSStatus error: [-34018] Security error has occurred.
No string returned
No data returned
Running the same on a real device, it works:
Returned string: ABC
Data was returned
In the console I see the same messages about about entitlement and provisioning profile as in the first message.