-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding plugins for only specific platforms #892
Comments
Personally I'd support this kind of feature, but I don't know if overloading the I think it may better to introduce a new To solve the restoration issue, the Interested in hearing your thoughts on this.
Just to add another work around. The plugin could always be forked and have it's platform implementation removed (even just from it's |
Hi @breautek , thanks for the answer.
Adding a new "--platform" config would indeed be better engineering, however I don't have enough free time and low-level cordova knowledge to implement this. Not even sure about my own proposal, but I had some progress there. Also, --platform would require a breaking change in package.json layout I think. |
It would, but I think it can be implemented in a way that we can migrate a structure to a more extensible structure pretty easily. I'd have to check with some other PMC members first though.
That's okay. Apache is no obligation, 100% volunteers. This would likely be an iterative change anyway. E.g. a few PRs would have to be made before this issue can be tackled. That's assuming the new |
I have another idea to implement it with a hook which would be much simpler and still automated, however there is no hook for that. Simply an "after_plugin_fetch" hook could modify the plugin.xml and remove the undesired platforms and that's it. It is also restorable. No need to clone the plugin or deal with merge conflicts. While this solution would be up to the user to implement with a hook, it is straightforward. In this case, we just need to add a few lines of code to Also, I got another idea on implementing a built-in feature without using --platform or --variable as well. For example; suppose that config.xml might have an element that contains blacklist of certain plugin ids for specific platforms. |
There is a number of hooks. That's a good idea, that's probably the most elegant way of working around this issue. Would the existing https://cordova.apache.org/docs/en/11.x/guide/appdev/hooks/index.html |
They don't help here because plugins are already installed to the platform when they are called. |
Sent from Yahoo Mail for iPhone
On Thursday, May 5, 2022, 12:39 PM, Arda Beyazoğlu ***@***.***> wrote:
They don't help here because plugins are already installed to the platform when they are called.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Still need this in 2024. For example: The only way I found how to fix that is to manually edit the I think using hooks is a good idea for a workaround, but ignoring the unsupportable platforms during plugin installation looks a way better approach. |
In onesignal's case, they are providing a JS module for all platforms (because it's not isolated inside a |
Thank you for quick response! I will create an issue in plugin repo. |
Feature Request
I want to add some plugins to only single platform or skip for a certain platform. I already found a way to implement this, and I am willing to develop this feature and send a pull request if approved.
Motivation Behind Feature
Multi platform apps do not always require same functionality. For example, I may have a client who needs nfc features and use only android devices, whereas ios clients don't need them. Besides, one may prefer not to add some specific functionality to each platform although device supports it.
So why not just add the plugin and don't implement the feature ?
Short answer: to avoid unnecessary approval trouble. For example; If I add phonegap-nfc plugin, the apple approval team see that I am using nfc and ask me to prove how I use it and why I use it ? It is very hard to show what you don't implement and the apple team will not approve it until they see a convincing explanation / proof.
The issue becomes especially important when developing ad-hoc apps for customers instead of product apps that are usually same across platforms.
Feature Description
It can be implemented using cli variables that are already built in. A global variable, non conflicting variable such as "cordova-platform" can be used:
cordova plugin add some-cordova-plugin --variable cordova-platform=android
cordova plugin add some-cordova-plugin --variable cordova-platform=android,browser
The command skips install steps for unspecified platforms and save preference to config.xml, so that when a platform is added/removed it can repeat the same behaviour.
Alternatives or Workarounds
It is impossible to do it without manual intervention right now. The only way is to add plugin and then delete specific folders and files which is quite cumbersome and highly repetitive.
The text was updated successfully, but these errors were encountered: