nordnet / cordova-universal-links-plugin

[DEPRECATED] - Cordova plugin to support Universal/Deep Links for iOS/Android.
https://github.com/nordnet/cordova-universal-links-plugin/issues/160
MIT License
349 stars 530 forks source link

Two entitlements files #8

Closed mikeduarte closed 6 years ago

mikeduarte commented 8 years ago

@nikDemyankov

Hi again,

One more question about the plugin. I am using Xcode 7.0.1 and before I installed your plugin, my Cordova project already had an entitlements file in the Root directory with an entry for webcredentials:mydomain.com. The name of the file being My Project.entitlements. When I do a Cordova Prepare command, the plugin adds another entitlements file in the Resources directory with applinks:www.mydomain.com and the file has the exact same name as the other entitlements file in the ROOT directory. Everything works fine with the universal links as I posted before in the other post. My question is whether this is a bug or intentional?

I also noticed that under Build Settings > Code Signing > Code Signing Entitlements is pointing the entitlements file that the plugin created in the Resources directory.

Thanks!

nikDemyankov commented 8 years ago

This is not a bug, this is totally fine. You can have as many entitlements files as you want.

From the native developer perspective, to enable Universal Links in Xcode you need to:

  1. Open Capabilities tab of your project and activate Associated Domains feature.
  2. Add there records in format: applinks:<your_domain>, where <your_domain> is... your domain :)

As a result, Xcode will generate .entitlements file with proper data. And this file is usually created in the root folder of the project.

Our plugin does all that on a cordova build phase (or ionic build):

Why do I put it in the Resources folder? No reason, actually. Just because I like it to be there. Plus less chances of conflicts with the existing entitlement file. If you want - you can move it.

mikeduarte commented 8 years ago

Excellent, thank you again for the thorough explanation. Everything is working very well, great work!

nikDemyankov commented 8 years ago

Thanks :)

MarsupiL commented 7 years ago

Hi Nik, I am having a related issue with v1.2.1 of the plugin. I can see the /Resources/myApp.entitlements file being created but it doesn't seem to be added to the build target as you mention, nor is the path to the /Resources folder added to the 'CODE_SIGN_ENTITLEMENTS'. It only seems to be added to the build when placed under the root folder of the project. I'm running Cordova 6.4.0 and build for iOS >9.0 Am I missing anything?

adityasaxena commented 7 years ago

@MarsupiL I'm facing the same issue. I see the file under Resources/<appname>.entitlements but XCode cannot seem to recognize it. That is why when I look under the Associated Domains under Capabilities, none of the links are there. Any idea why ? cc @nikDemyankov

Thank you very much for your help in advance!

nikDemyankov commented 7 years ago

Hi @adityasaxena @MarsupiL,

Tried it on the fresh project and .entitlements file was added to the project, and I can see Associated Domains active in the Capabilities tab.

Can you give me some more info, please:

  1. Have you tried it on the new project, that has no other plugins? If not, please, do.
  2. What node version you are using?
  3. What cordova iOS platform version you are using?
  4. Maybe some step-by-step guide how to get this error...

If I would be able to reproduce it - I should be able to fix it...

MarsupiL commented 7 years ago

I haven't tried on a new project yet, but I managed to fix it using the cordova-custom-config plugin to add the CODE_SIGN_ENTITLEMENTS and the content of the Entitlements-Debug.plist and Entitlements-Release.plist files introduced in Cordova-ios 4.3.0. I'm using node 7.0.0 and Cordova-ios 4.3.1

nikDemyankov commented 7 years ago

Prior to 4.3.0 Cordova didn't have entitlements file, so I had to implement a custom hook that will generate it and add to the Xcode project. But now they do - so yes, one way to go is to use your approach. Although, it's strange that you are facing this issue :(

MarsupiL commented 7 years ago

So I created a new project and can confirm that there is a conflict with the cordova-custom-config plugin. The plugin itself does not create issues but as soon as I set any preference for an XCBuildConfiguration element in the config file it seems to remove the CODE_SIGN_ENTITLEMENTS set to /Resources/myProject.entitlements defined by your plugin. Unfortunately I do need to use this plugin to set up various config elements :/

nikDemyankov commented 7 years ago

Okay, thanks for the input, will check it out. At least now I know how to reproduce it.

MarsupiL commented 7 years ago

Correction: even without any custom config preference set, the custom-config plugin overrides the entitlements set in the project.pbxproj Maybe you can just change the hook to before_compile, since custom-config installs on after_prepare and changing it to before_prepare doesn't seem to add all config changes.

dpa99c commented 7 years ago

I'm the author of the cordova-custom-config plugin and I've finally made some time to look into this.

I'm unable to reproduce a scenario where this plugin causes the loss of the reference to the entitlements file created by the universal links plugin - see this screencapture for my test results.

For more details, see my last comment regarding this on the issue opened against cordova-custom-config regarding this behaviour.

djett41 commented 7 years ago

@dpa99c and @nikDemyankov this is definitely an issue for anyone who uses the Cordova CLI as its intended. If you do a "cordova platform add ios" without any plugins, and look at the build.xcconfig file for ios, this points to the Entitlements file that should contain all of your capabilities such as push, or whatever else..

CODE_SIGN_ENTITLEMENTS = $(PROJECT_DIR)/$(PROJECT_NAME)/Entitlements-$(CONFIGURATION).plist

When plugins modify the value of CODE_SIGN_ENTITLEMENTS for their own purposes and point to Resources/{appName}.entitlements, they dont merge with the capabilities or other config thats already set in Cordova's Entitlements-debug.plist or Entitlements-release.plist files. This messes up Cordovas automatic release/export through the CLI because now you're required to manually change capabilities before building/releasing. This is a problem for people who use the Cordova CLI as intended to where you shouldnt even need to open Xcode and can do Continuous integration builds.

Basically, plugins need to upgrade their hooks to set entitlements values in Cordovas Entitlements-debug.plist and Entitlements-release.plist files that are generated with the CLI, rather than invalidating those files

dpa99c commented 7 years ago

Update: I found and fixed a bug (see #108) which should resolve this issue when this plugin is used in conjunction with cordova-custom-config. The bug has nothing to do directly with modification of CODE_SIGN_ENTITLEMENTS, but was a race condition in file I/O which caused cordova-custom-config to overwrite modifications made by this (and other) plugins.

The fix has been published in a patch release: cordova-custom-config@3.1.3

adityasaxena commented 7 years ago

Thanks so much! I had fixed this in another plugin but that was in internal thing. Glad we have the fix now. Cheers!

chr4ss1 commented 7 years ago

the problem is still there. Use https://github.com/chancezeus/cordova-universal-links-plugin in mean while, it has the problem fixed.

nordnet-deprecation-bot commented 6 years ago

👋 Hi! Thank you for your interest in this repo.

đŸ˜ĸ We are not using nordnet/cordova-universal-links-plugin anymore, and we lack the manpower and the experience needed to maintain it. We are aware of the inconveniece that this may cause you. Feel free to use it as is, or create your own fork.

🔒 This will now be closed & locked.

ℹī¸ Please see #160 for more information.