EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 444 forks source link

Android build fails due to missing iOS folder to place the entitlements #223

Closed PanayotCankov closed 7 years ago

PanayotCankov commented 7 years ago

Executing after-prepare hook from /Users/cankov/git/NativeScript/nativescript-marketplace-demo/hooks/after-prepare/firebase-install-ios-entitlements.js fs.js:808 return binding.readdir(pathModule._makeLong(path)); ^

Error: ENOENT: no such file or directory, scandir 'platforms/ios' at Error (native) at Object.fs.readdirSync (fs.js:808:18) at Object. (/Users/cankov/git/NativeScript/nativescript-marketplace-demo/hooks/after-prepare/firebase-install-ios-entitlements.js:3709:15) at __webpack_require__ (/Users/cankov/git/NativeScript/nativescript-marketplace-demo/hooks/after-prepare/firebase-install-ios-entitlements.js:20:30) at /Users/cankov/git/NativeScript/nativescript-marketplace-demo/hooks/after-prepare/firebase-install-ios-entitlements.js:64:18 at Object. (/Users/cankov/git/NativeScript/nativescript-marketplace-demo/hooks/after-prepare/firebase-install-ios-entitlements.js:67:10) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12)

That's when building for android.

PanayotCankov commented 7 years ago

The plugin will copy KeychainSharing.entitlements from the plugin into the Xcode project and will add CODE_SIGN_ENTITLEMENTS that use the entitlement in the build process but this will not allow the developers to extend the capabilities of their app further than the keychain sharing. There are other capabilities that are set in the .entitlements file and so I think it would be best if the .entitlements are handled by the CLI to avoid clashes with other plugins or functionality manually extended in the app.

I was adding .entitlements by placing such file in the App_Resources/iOS/app.entitlements and was referencing it with the build.xcconfig:

// Entitlements
CODE_SIGN_ENTITLEMENTS = nativescriptmarketplacedemo/Resources/nativescriptmarketplacedemo.entitlements;

I am not sure my approach will work now with your plugin. Nor the:

<?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>aps-environment</key>
    <string>development</string>
</dict>
</plist>

Will be merged with the:

<?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)__KEYCHAIN_ACCESS_GROUP__</string>
    </array>
</dict>
</plist>
EddyVerbruggen commented 7 years ago

Hmm, good points.. tough one..

EddyVerbruggen commented 7 years ago

Tried enabling a few capabilities and this is what's written to .entitlements:

<?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>aps-environment</key>
    <string>development</string>
    <key>com.apple.developer.healthkit</key>
    <true/>
    <key>keychain-access-groups</key>
    <array>
        <string>$(AppIdentifierPrefix)org.nativescript.firebasedemo</string>
    </array>
</dict>
</plist>

So we def need to change this.

What about detecting whether or not .entitlements file exists and if so use the plist npm package to add the keychain-access-groups bit in case it's not there yet?

PanayotCankov commented 7 years ago

Honestly I don't know.

EddyVerbruggen commented 7 years ago

No worries, I'll take a stab at it shortly 👍

PanayotCankov commented 7 years ago

Btw the PR #222 may fix this issue.

PanayotCankov commented 7 years ago

Also I would be happy to get more input into: https://github.com/NativeScript/NativeScript/issues/3157