Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Two entitlements files #8

Closed
mikeduarte opened this issue Oct 9, 2015 · 17 comments
Closed

Two entitlements files #8

mikeduarte opened this issue Oct 9, 2015 · 17 comments
Labels

Comments

@mikeduarte
Copy link

@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
Copy link
Member

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):

  • Creates .entitlements file if it doesn't exist in the Resources folder. If it does - it will append data to it.
  • Put's there all hosts, that you defined in config.xml.
  • Add's that file to the build target.
  • Add's it to the Code Signing Entitlements because it is a custom entitlements file.

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
Copy link
Author

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

@nikDemyankov
Copy link
Member

Thanks :)

@MarsupiL
Copy link

MarsupiL commented Dec 6, 2016

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
Copy link

@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 nikDemyankov reopened this Dec 8, 2016
@nikDemyankov
Copy link
Member

nikDemyankov commented Dec 8, 2016

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
Copy link

MarsupiL commented Dec 8, 2016

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
Copy link
Member

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
Copy link

MarsupiL commented Dec 13, 2016

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
Copy link
Member

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

@MarsupiL
Copy link

MarsupiL commented Dec 14, 2016

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
Copy link
Contributor

dpa99c commented Mar 21, 2017

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
Copy link

djett41 commented Mar 27, 2017

@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
Copy link
Contributor

dpa99c commented Apr 7, 2017

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
Copy link

adityasaxena commented Apr 7, 2017 via email

@chr4ss1
Copy link

chr4ss1 commented Jun 21, 2017

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
Copy link
Contributor

👋 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.

@nordnet nordnet locked and limited conversation to collaborators Sep 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants