Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

iOS simulator "An error occurred when accessing the keychain" #627

Closed
jcroughton opened this issue Feb 19, 2018 · 1 comment
Closed

iOS simulator "An error occurred when accessing the keychain" #627

jcroughton opened this issue Feb 19, 2018 · 1 comment

Comments

@jcroughton
Copy link

jcroughton commented Feb 19, 2018

Environment

node v8.94
npm 5.6.0
xcode 9.2
nativescript 3.4.2
nativescript-plugin-firebase ^5.1.6

Appropriate Firebase authentication methods enabled.

Description

Trying to get user creation / login / getCurrentUser working (anonymous, email/password creation and login types) but constant "An error occurred when accessing the keychain" errors. Entitlements fixes have been tried (see below).

Any advice greatly appreciated.

Examples

firebase.createUser({
    email: '[email protected]',
    password: '123456'
})
.
.
.

Result

Error raised "An error occurred when accessing the keychain..."
User created ok on firebase

firebase.login({
    type: firebase.LoginType.PASSWORD,
    passwordOptions: {
        email: '[email protected]',
        password: '123456'
    }
})
.
.
.

Result

Error raised "An error occurred when accessing the keychain..."
getCurrentUser fails

Fixes tried

The following fixes re entitlements as per #420 have been tried

app/App_Resources/iOS/org.nativescript.mayappname.entitlements

Content

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.keystore.access-keychain-keys</key>
    <true/>
    <key>com.apple.keystore.device</key>
    <true/>
</dict>
</plist>

Causes An error occurred when accessing the keychain

app/App_Resources/iOS/*.entitlements

Content

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>keychain-access-groups</key>
  <array>
    <string>$(AppIdentifierPrefix)com.Company.Product</string>
  </array>
</dict>
</plist>

Causes Error is: Expected "/" or [^*] but "" found.
App never launches in simulator.

@jcroughton
Copy link
Author

I eventually solved this issue. Hopefully the following may help anyone else who arrives here.

Actions taken:

tns platform remove ios && tns platform add ios && tns run ios
Open project in Xcode
Select project folder in project navigator (left sidebar)
Ensure appropriate target selected in main area top nav
Select General / signing / Team / personal team
Select Capabilities in main area top nav
Keychain sharing / Toggle switch to on / select appropriate dev team (personal is ok).
Ignore Signing for xyz requires a development team if it appears
Expand project folder (left sidebar)
Expand inner folder (same name as project)
Note newly created yourprojectname.entitlements file
Right-click yourprojectname.entitlements file / show in finder
Copy generated yourappname.entitlements to app/App_Resources/iOS/yourappname.entitlements

Note app/App_Resources/iOS/build.xcconfig is also updated (by Xcode) to contain

CODE_SIGN_ENTITLEMENTS = yourappname/yourappname.entitlements

Naming of entitlements file in instructions / other issues seems ambiguous. It is NOT the entire package.json nativescript id, for instance

Where package.json nativescript id is

org.nativescript.yourappname

Then entitlements file name will be

yourappname.entitlements

The contents of the resultant entitlements file were

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>keychain-access-groups</key>
	<array>
		<string>$(AppIdentifierPrefix)org.nativescript.yourappname</string>
	</array>
</dict>
</plist>

Finally I tns platform remove ios && tns platform add ios && tns run ios

Repository owner deleted a comment from Maxatma Jan 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant