cordova/phonegap 插件添加 VS config.xml
cordova/phonegap plugin add VS config.xml
我发现 phonegap/cordova 插件有些令人困惑。
例如我可以运行
cordova plugin add cordova-plugin-whitelist
或
phonegap plugin add cordova-plugin-whitelist
这样做不会修改 config.xml
文件
或者我可以添加到 config.xml:
<plugin name="cordova-plugin-whitelist" spec="1.1.0" />
或
<gap:plugin name="cordova-plugin-whitelist" spec="1.1.0" />
所有这些不同的插件安装之间到底有什么区别?到底该用哪一个呢?
我希望所有其他开发人员计算机上都可以使用相同的插件,版本完全相同,以拥有稳定且可重现的环境(而且 CLI 似乎没有指定版本...)。我应该将 /plugins
文件夹中的任何内容添加到 Git 吗?
注意:如果重要的话,我还不知道我将来会使用哪个 cordova 或 phonegap CLI,因为我还不知道我是否会使用 Phonegap Build。目前,两个 CLI (v5.1.1) 似乎都运行良好。
您应该开始阅读有关 PhoneGap 和 Cordova 之间的区别(有 none)- 可以在此处找到更多信息:Difference between PhoneGap and Cordova.
命令 cordova plugin add cordova-plugin-console
不修改 config.xml
一定是您系统上的问题。我刚刚尝试过,可以肯定的是,这在 5.1.1 中按预期工作并且确实如此。
config.xml
在没有添加插件的情况下全新构建:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.com" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="DisallowOverscroll" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="GapBetweenPages" value="0" />
<preference name="PageLength" value="0" />
<preference name="PaginationBreakingMode" value="page" />
<preference name="PaginationMode" value="unpaginated" />
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage" />
</feature>
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<name>test</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
</widget>
添加cordova plugin add cordova-plugin-console
后底部新增三行:
<feature name="Console">
<param name="ios-package" value="CDVLogger" />
</feature>
gap:
是 config.xml
的 PhoneGap 设置
- 添加不同版本的插件将使用此命令:
cordova plugin add [PLUGIN_ID]@[VERSION]
- 我建议你用你需要的插件建立一个存储库,而不是有人应该关注这个并更新插件,这样其他人就可以在他们需要那个版本的时候将这些插件分叉到他们的计算机上.
- 只要使用其中之一,PhoneGap 或 Cordova,因为没有区别。
使用:
cordova plugin add cordova-plugin-whitelist --save
答案很长。请阅读。
What are exactly the differences between all these different plugin installations? Which one should I use in the end?
直到这个日期 (2015-11-05) 以及更长的时间,不同的插件之间存在细微差别。 Cordova 和 Phonegap 正在努力消除它。对于所有密集用途,您应该使用 *NEW* 插件存储库
新插件存储库:http://cordova.apache.org/plugins/
新核心插件列表:http://cordova.apache.org/docs/en/5.1.1/cordova/plugins/pluginapis.html
(注意:不在此列表中的插件 不是核心 。)
I want the same plugins to be available on all the other developers computers, in the exact same version to have a stable and reproductible environment (and the CLI does not seem to specify the version...). Should I include anything of my /plugins folder to Git?
没有。现在,只需使用当前的 NPM 系统即可。您可能希望使用 --save
选项,以便保留您正在使用的插件的副本。注意:这有副作用。阅读 Cordova docs 了解更多信息。
团队注意事项:许多框架希望您使用“前沿”优势,以“最新最好”的名义出售。这有很多很多副作用。 Cordova 和 Phonegap 都有版本控制选项。学习使用它。
这将有助于:
http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/
HOW TO apply the Cordova/Phonegap the whitelist system
我引用:
Here is the breakdown.
For the whitelist system used with Cordova, there is actually four (4) unrelated systems in place.
- legacy-whitelist plugin (avoid) was the previous whitelist system. It is provided for backwards compatibilty only.
- whitelist plugin (Cordova's) is the new whitelist system. It is required as of Cordova Tools 4.0.0. It has three (3) parts.
- W3's CSP (Content Security Policy Level 2) is a whitelist system that is implemented webpage by webpage. It is required as of Cordova Tools 5.0.0. It has sixteen (16) parts.
- Apple's ATS (App Transport Security) is a whitelist system exclusive to iOS. It required as of iOS9. It is implemented in the Info.plist
<gap:plugin name="cordova-plugin-whitelist"npm />
有时使用这个如果你使用这个代码将无法工作
<gap:plugin name="cordova-plugin-whitelist" spec="1.1.0" />
我发现 phonegap/cordova 插件有些令人困惑。
例如我可以运行
cordova plugin add cordova-plugin-whitelist
或
phonegap plugin add cordova-plugin-whitelist
这样做不会修改 config.xml
文件
或者我可以添加到 config.xml:
<plugin name="cordova-plugin-whitelist" spec="1.1.0" />
或
<gap:plugin name="cordova-plugin-whitelist" spec="1.1.0" />
所有这些不同的插件安装之间到底有什么区别?到底该用哪一个呢?
我希望所有其他开发人员计算机上都可以使用相同的插件,版本完全相同,以拥有稳定且可重现的环境(而且 CLI 似乎没有指定版本...)。我应该将 /plugins
文件夹中的任何内容添加到 Git 吗?
注意:如果重要的话,我还不知道我将来会使用哪个 cordova 或 phonegap CLI,因为我还不知道我是否会使用 Phonegap Build。目前,两个 CLI (v5.1.1) 似乎都运行良好。
您应该开始阅读有关 PhoneGap 和 Cordova 之间的区别(有 none)- 可以在此处找到更多信息:Difference between PhoneGap and Cordova.
命令 cordova plugin add cordova-plugin-console
不修改 config.xml
一定是您系统上的问题。我刚刚尝试过,可以肯定的是,这在 5.1.1 中按预期工作并且确实如此。
config.xml
在没有添加插件的情况下全新构建:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.com" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="DisallowOverscroll" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="GapBetweenPages" value="0" />
<preference name="PageLength" value="0" />
<preference name="PaginationBreakingMode" value="page" />
<preference name="PaginationMode" value="unpaginated" />
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage" />
</feature>
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<name>test</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
</widget>
添加cordova plugin add cordova-plugin-console
后底部新增三行:
<feature name="Console">
<param name="ios-package" value="CDVLogger" />
</feature>
gap:
是config.xml
的 PhoneGap 设置
- 添加不同版本的插件将使用此命令:
cordova plugin add [PLUGIN_ID]@[VERSION]
- 我建议你用你需要的插件建立一个存储库,而不是有人应该关注这个并更新插件,这样其他人就可以在他们需要那个版本的时候将这些插件分叉到他们的计算机上.
- 只要使用其中之一,PhoneGap 或 Cordova,因为没有区别。
使用:
cordova plugin add cordova-plugin-whitelist --save
答案很长。请阅读。
What are exactly the differences between all these different plugin installations? Which one should I use in the end?
直到这个日期 (2015-11-05) 以及更长的时间,不同的插件之间存在细微差别。 Cordova 和 Phonegap 正在努力消除它。对于所有密集用途,您应该使用 *NEW* 插件存储库
新插件存储库:http://cordova.apache.org/plugins/
新核心插件列表:http://cordova.apache.org/docs/en/5.1.1/cordova/plugins/pluginapis.html (注意:不在此列表中的插件 不是核心 。)
I want the same plugins to be available on all the other developers computers, in the exact same version to have a stable and reproductible environment (and the CLI does not seem to specify the version...). Should I include anything of my /plugins folder to Git?
没有。现在,只需使用当前的 NPM 系统即可。您可能希望使用 --save
选项,以便保留您正在使用的插件的副本。注意:这有副作用。阅读 Cordova docs 了解更多信息。
团队注意事项:许多框架希望您使用“前沿”优势,以“最新最好”的名义出售。这有很多很多副作用。 Cordova 和 Phonegap 都有版本控制选项。学习使用它。
这将有助于: http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/
HOW TO apply the Cordova/Phonegap the whitelist system
我引用:
Here is the breakdown.
For the whitelist system used with Cordova, there is actually four (4) unrelated systems in place.
- legacy-whitelist plugin (avoid) was the previous whitelist system. It is provided for backwards compatibilty only.
- whitelist plugin (Cordova's) is the new whitelist system. It is required as of Cordova Tools 4.0.0. It has three (3) parts.
- W3's CSP (Content Security Policy Level 2) is a whitelist system that is implemented webpage by webpage. It is required as of Cordova Tools 5.0.0. It has sixteen (16) parts.
- Apple's ATS (App Transport Security) is a whitelist system exclusive to iOS. It required as of iOS9. It is implemented in the Info.plist
<gap:plugin name="cordova-plugin-whitelist"npm />
有时使用这个如果你使用这个代码将无法工作
<gap:plugin name="cordova-plugin-whitelist" spec="1.1.0" />