Cordova 未构建 - Platform Config.xml 不正确
Posted
技术标签:
【中文标题】Cordova 未构建 - Platform Config.xml 不正确【英文标题】:Cordova does not build - Platform Config.xml incorrect 【发布时间】:2016-08-23 08:22:38 【问题描述】:我正在使用 Cordova 6.3.1。
尝试使用 Cordova CLI 构建到 ios 会出现如下所示的问题。
$ cordova build ios
Error: Pruning at selector "/widget/plugins" from "/Users/path/to/cordova/project/cordova/platforms/ios/Myproj/config.xml" went bad.
更新平台时我也遇到同样的错误:
$ cordova platform update ios
Updating ios project...
iOS project updated with cordova-ios@4.2.1
Error: Pruning at selector "/widget/plugins" from "/Users/path/to/cordova/project/cordova/platforms/ios/Myproj/config.xml" went bad.
1) 这个剪枝错误到底是什么意思?
我注意到位于 cordova/platforms/ios/Myproj/ 中的 config.xml 不包含来自我的根 config.xml 的任何信息。它只是像这样开始的默认文件:
<widget xmlns = "http://www.w3.org/ns/widgets"
id = "io.cordova.helloCordova"
version = "2.0.0">
<name>HelloCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
我的根 config.xml 文件是这样开始的:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myproj.app" version="1.0.38" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Myproj</name>
<description>
Some description.
</description>
同时,当我执行以下添加平台时,安装似乎很好:
$ cordova platform add ios
Adding ios project...
Creating Cordova project for the iOS platform:
Path: ../../../../../desktop/dev/path/to/my/project/cordova/platforms/ios
Package: com.myproj.app
Name: Myproj
iOS project created with cordova-ios@4.2.1
Installing "com.mbppower.camerapreview" for ios
Installing "com.phonegap.plugins.PushPlugin" for ios
Installing "cordova-plugin-device" for ios
Installing "cordova-plugin-globalization" for ios
Installing "com.telerik.plugins.healthkit" for ios
Installing "com.transistorsoft.cordova.background-geolocation" for ios
Installing "cordova-plugin-dialogs" for ios
Installing "cordova-plugin-background-fetch" for ios
Installing "cordova-plugin-afnetworking" for ios
Plugin "cordova-plugin-background-fetch" already installed on ios. Making it top-level.
Installing "cordova-plugin-camera" for ios
Installing "cordova-plugin-compat" for ios
Dependent plugin "cordova-plugin-compat" already installed on ios.
Installing "cordova-plugin-console" for ios
Plugin "cordova-plugin-device" already installed on ios. Making it top-level.
Plugin "cordova-plugin-dialogs" already installed on ios. Making it top-level.
Installing "cordova-plugin-file" for ios
Dependent plugin "cordova-plugin-compat" already installed on ios.
The android Persistent storage location now defaults to "Internal". Please check this plugins README to see if you application needs any changes in its config.xml.
If this is a new application no changes are required.
If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:
"<preference name="AndroidPersistentFileLocation" value="Compatibility" />"
to config.xml in order for the application to find previously stored files.
Installing "cordova-plugin-file-transfer" for ios
Dependent plugin "cordova-plugin-file" already installed on ios.
Installing "cordova-plugin-geolocation" for ios
Dependent plugin "cordova-plugin-compat" already installed on ios.
Dependent plugin "cordova-plugin-globalization" already installed on ios.
Installing "cordova-plugin-http" for ios
Dependent plugin "cordova-plugin-file" already installed on ios.
Installing "cordova-plugin-inappbrowser" for ios
Installing "cordova-plugin-media-capture" for ios
Dependent plugin "cordova-plugin-file" already installed on ios.
Dependent plugin "cordova-plugin-compat" already installed on ios.
Installing "cordova-plugin-pedometer" for ios
Installing "cordova-plugin-photokandy-video-thumbnail" for ios
Dependent plugin "cordova-plugin-file" already installed on ios.
Installing "cordova-plugin-whitelist" for ios
Installing "phonegap-plugin-barcodescanner" for ios
2) 平台安装如何工作?更具体地说,它如何告诉平台特定的 config.xml 中应该包含什么?
我希望可以在使我的构建运行的上下文中回答这些问题。其他一些背景信息:我正在使用 Sencha Touch 并使用启动原始 Cordova 项目文件夹的 Sencha Cmd 与 $sencha app build native
一起构建。
【问题讨论】:
【参考方案1】:
cordova plugins --list
打开 x-code 找到这些插件
也许科尔多瓦插件列表有一些插件,但 ios 项目没有。
您可以自己删除它并重新安装
platform > ios > fecth.json or ios.json or package.json
希望有帮助
对不起,我英语不好。
【讨论】:
【参考方案2】:对我来说,这篇文章的解决方案是: Cordova pruning error for android config xml
您必须删除所有插件和平台,更新cordova,然后再次添加所有插件和平台。为了清理插件和我的 ios 平台,我编写了一个 npm 脚本:
...
"rm-plugins": "cordova plugins list | awk 'print $1' | xargs cordova plugins rm",
"rm-platforms": "cordova platforms remove ios",
"cleanup": "npm run rm-platforms && npm run rm-plugins && npm update cordova"
...
PS:我的错误信息和你的不完全一样:
Error: Pruning at selector "/*/plugins" from "/Users/Thomas/work/repos/nexboard/iOS/nexboard/platforms/ios/neXboard/config.xml" went bad.
【讨论】:
以上是关于Cordova 未构建 - Platform Config.xml 不正确的主要内容,如果未能解决你的问题,请参考以下文章
cordova windows 构建错误(未检测到所选目标的有效 MSBuild) - 检查所有 Cordova 要求