title: "An error occurred when accessing the keychain"
body: <p>I use Firebase Auth plugin for Flutter in order to sign in with Google in my app, and it <strong>works fine</strong> in both iOS and Android.</p>
  
  <p>My problem starts when I try to use Firebase Auth in my iOS "Share Extension". I am new to iOS so I am not really familiar with Swift and Xcode, but as far as I understand I should <a href="https://firebase.google.com/docs/auth/ios/single-sign-on" rel="nofollow noreferrer">enable cross-app authentication with shared iOS Keychain</a> in order to authenticate the user in my shared extension. </p>
  
  <p>I have 2 targets in my project, the "Runner" and the "Share Extension" so I have enabled the Keychain Sharing for both of them:</p>
  
  <p><a href="https://i.stack.imgur.com/ee7NU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ee7NU.png" alt="enter image description here"></a></p>
  
  <p>When the Keychain Sharing is enabled, I get the following error when I try to sign in using Firebase Auth:</p>
  
  <pre><code>Unhandled Exception: PlatformException(ERROR_KEYCHAIN_ERROR, An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered, null)
  #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
  #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
  &lt;asynchronous suspension&gt;
  #2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:349:48)
  #3      MethodChannelFirebaseAuth.signInWithCredential (package:firebase_auth_platform_interface/src/method_channel_firebase_auth.dart:161:23)
  #4      FirebaseAuth.signInWithCredential (package:firebase_auth/src/firebase_auth.dart:208:10)
  #5      signInWithGoogle (package:matkonit/google_sign_in.dart:17:45)
  &lt;asynchronous suspension&gt;
  #6      LoginPageState.signInButton.&lt;anonymous closure&gt;.&lt;anonymous clo&lt;…&gt;
  </code></pre>
  
  <p>This is what I get when I print the <strong>NSLocalizedFailureReasonErrorKey</strong>:</p>
  
  <pre><code>SecItemCopyMatching (-34018)
  </code></pre>
  
  <p>What can I do in order to fix this?</p>
  
  <hr>
  
  <p><strong>Edit:</strong> I have noticed that restarting the simulator makes the sign in work, but only sometimes... I couldn't figure out why.</p>