KeychainItemWrapper crash on iOS10
Asked Answered
T

2

5

When I try to add the item to Keychain i found this crash on iOS10 *** Assertion failure in -[KeychainItemWrapper writeToKeychain]

On iOS 9.3 I write the key in the keychain without problem Thanks

Tannertannery answered 18/9, 2016 at 18:13 Comment(0)
F
8

It looks like a bug; a bug report has been filed, but there's a workaround. Just enable "Keychain Sharing" (under your app -> Capabilities tab in Xcode). See https://forums.developer.apple.com/thread/51071 for full background.

Frith answered 21/9, 2016 at 7:12 Comment(1)
keychain is keep breaking very frequently with the following iOS releases, they should provide a proper library to deal with this, thanks for posting the fix!Audly
G
0

Edit: Ignore what I was rambling about... duh, forgot that under the project target's Capabilities tab I have also enabled Keychain sharing... Though still would like to get a deeper, more cogent answer.

So guess you can ignore this... but leaving here just in case you run into the privacy stuff (though that's another SO question which I'm sured has been answered elsewhere):

Yeah, I had the same problem (also with asking for location crashing)... looks like a change in iOS 10 regarding privacy and services. Strangely in my case adding the keys below this comment to the info.plist (or via Xcode you'll see them with "Privacy-*")

Funny thing is that suddenly keychain access worked just fine, even though none of these keys have anything to do with keychain access... I'm still digging more into that so I can provide a "real answer", but hopefully this can unblock you for now.

Here's what I added (note don't think you need all of them, but just to ensure my answer matches what I did):

<key>LSApplicationCategoryType</key>
<string></string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>health devices</string>
<key>NSRemindersUsageDescription</key>
<string>medication reminders</string>
<key>NSMicrophoneUsageDescription</key>
<string>calls</string>
<key>NSCameraUsageDescription</key>
<string>Allow Moonshot to use the camera (profile and calls)</string>
<key>NSMotionUsageDescription</key>
<string>Allow Moonshot to use motion to track activity</string>
<key>NSLocationUsageDescription</key>
<string>Allow Moonshot to use location to track activity</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Allow Moonshot to always use location (to track activity)</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow Moonshot to use location while in use (to track activity)</string>
<key>CFBundleDevelopmentRegion</key>
Gnarly answered 19/9, 2016 at 8:26 Comment(1)
thanks :) I enable the keychain sharing to the Capabilities section and the app work normallyTannertannery

© 2022 - 2024 — McMap. All rights reserved.