Note: This post’s primary purpose is to help me think through this problem. I have no prescribed solution at the end of it. The conversation will continue on Stack Overflow. I will update this post once I have a final approach.
This happens because we can’t access the keychain to get (or create) the key to en/decrypt the Realm. The default
kSecAttrAccessible value is
There are a few options as I see them:
kSecAttrAccessibleAlways. I don’t like this because it’s a) too open and b) it was slated to be deprecated in iOS 9
kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly. This is better but still feels too open to me, even though the docs state: This is recommended for items that need to be accessed by background applications
I’m currently trying to decide if #2, if #3 is worth putting the time into, or if I can come up with a #5