Setup
- Swift app with each iOS and macOS targets with the identical bundle id:
com.teamName.appName
- App group:
group.com.teamName.appName
- Keychain sharing group:
com.teamName.appName
- Authentication setup:
strive Auth.auth().useUserAccessGroup("group.com.teamName.appName")
- This setup is important for sustaining sign-in state in app extensions (notifications, share extension)
Concern
- iOS: Auth state persists appropriately
- macOS: Requires re-authentication every time
- Error on macOS:
Error Area=FIRAuthErrorDomain Code=17995 "An error occurred when accessing the keychain."
Tried Repair
- Modified app group from
group.com.teamName.appName
toteamId.group.com.teamName.appName
- This method mimics the automated conduct for keychain teams
- Reasoning behind the repair:
a. Keychain teams mechanically prepend the crew ID within the entitlements file. For instance, setting the keychain group ascom.teamName.AppName
within the goal really units it as$(AppIdentifierPrefix)com.teamName.AppName
within the entitlements
b. The speculation was that app teams would possibly want related remedy for macOS - Implementation:
a. Modified the app group identifier within the venture settings
b. Up to date theuseUserAccessGroup
name within the authentication setup:
strive Auth.auth().useUserAccessGroup("teamId.group.com.teamName.appName")
c. Adjusted some other references to the app group all through the codebase
Consequence
- macOS: Compiles, runs, and persists authentication
- iOS: Fails to compile on bodily system with error:
Software Group identifiers ought to begin with ‘group.’ - (Observe: Compiles fantastic in simulator)
Query
How can I resolve this problem to have each iOS and macOS apps compile, run, and persist their authentication state? Is there a means to make use of completely different app group identifiers for iOS and macOS inside the similar goal, or ought to I contemplate separating the targets?