Keychain Crash

This troubleshooting guidance applies only to MobilePush SDK for iOS versions 8.0.13 and earlier.

Important

Fatal Keychain Access exceptions occur if an application with an active SDK integration tries to access Keychain on a locked device secured with Face ID or passcode-based authentication. iOS Data Protection modes prevent the SDK from accessing these files.

These sections describe common Keychain Access exceptions and provide guidance on resolving them.

Common errSecInteractionNotAllowed Exceptions 

These are common occurrences of the errSecInteractionNotAllowed exception:

  • Fatal Exception: com.salesforce.security.keychainException dictionaryItemFromKeychain: Error attempting to look up keychain item: errSecInteractionNotAllowed
  • Fatal Exception: com.salesforce.security.keychainException setObject:forKey:: Error saving value to the keychain: errSecInteractionNotAllowed.
  • Fatal Exception: com.salesforce.security.keychainException writeToKeychain: Error adding keychain item: errSecInteractionNotAllowed.

To resolve errSecInteractionNotAllowed exceptions, follow these steps.

  • Upgrade to SDK for iOS version 8.0.8 or later and Marketing Cloud SDK version 1.0.6 or later.

  • Before initializing the SDK, set the setKeychainAccessErrorsAreFatal method to false.

    1SFMCSdk.setKeychainAccessErrorsAreFatal(errorsAreFatal: false)

    Setting this property to false logs the exception to the console instead of causing the app to crash.

Unknown Status Code (-34018) 

You can encounter an error message that indicates a keychain access issue along with an unknown status code (-34018).

1Terminating app due to uncaught exception 'com.salesforce.security.keychainException',
2reason: 'dictionaryItemFromKeychain: Error attempting to look up keychain item:
3Unknown status code (-34018)'

To resolve this issue, enable Keychain Sharing in the Signing & Capabilities pane in Xcode. When you enable Keychain Sharing, you don’t need to add identifiers specific to the SDK.

Related Items 

For an example of an ideal SDK implementation on iOS, see the iOS LearningApp.

Not all the code used in the LearningApp is required. Depending on your app, you can decide which parts to implement and which to ignore.