Skip to content

[Bug?] Unsafe to call useUserAccessGroup immediately after FirebaseApp.configure() #4175

Closed
@mobmad

Description

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 11.1 (11A1027)
  • Firebase SDK version: 6.11
  • Firebase Component: Auth
  • Component version: 6.3.1

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

  1. Follow the steps in Enabling cross-app authentication with shared iOS Keychain
  2. Do the following:
// ... inside application(_:didFinishLaunchingWithOptions:):
FirebaseApp.configure()

do {
    try Auth.auth().useUserAccessGroup("TEAMID.com.example.group1")
    print("useUserAccessGroup OK")
} catch let error as NSError {
    print("useUserAccessGroup failed with \(error)")
}

Expected output:
useUserAccessGroup OK

Actual output:
useUserAccessGroup failed with Error Domain=Foundation._GenericObjCError Code=0 "(null)"

My analysis

It seems like there is some async setup going on which prevents this from working. If I wrap the useUserAccessGroup call with

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
	do {
	    try Auth.auth().useUserAccessGroup("TEAMID.com.example.group1")
	    print("useUserAccessGroup OK")
	} catch let error as NSError {
	    print("useUserAccessGroup failed with \()")
	}
}

or move it out of application(_:didFinishLaunchingWithOptions:): and call it later it works as expected.

I think this is a bug, but if it's not, I would suggest improving the error message to something more helpful.

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions