apache / apache/cordova-lib

Adding plugins for only specific platforms

Open
#892 12 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
231
Forks
242
Avg merge
2h 51m
Merged PRs (30d)
7

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.