xcode Cordova iOS 插件在构建后失败,除非我先删除平台和插件 JSON
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20326504/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cordova iOS Plugins fail after building, unless I remove platform and plugin JSON first
提问by bbodien
I have a Cordova 3.2.0 project, and I'm testing using the XCode emulator and an iPhone 4S over USB.
我有一个 Cordova 3.2.0 项目,我正在通过 USB 使用 XCode 模拟器和 iPhone 4S 进行测试。
When I execute the following, the app runs without error:
当我执行以下操作时,应用程序运行没有错误:
rm -rf platforms/ios
rm plugins/ios.json
cordova platforms add ios
cordova build ios
If I then make any kind of change to my code, and re-run:
如果我对代码进行任何类型的更改,然后重新运行:
cordova build ios
I get the following errors when launching the app in XCode:
在 XCode 中启动应用程序时出现以下错误:
ERROR: Plugin 'StatusBar' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 2013-12-02 10:50:26.136 treemedia[774:60b] -[CDVCommandQueue executePending] [Line 127] FAILED pluginJSON = [ "INVALID", "StatusBar", "_ready", [ ] ]
ERROR: Plugin 'Device' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 2013-12-02 10:50:26.140 treemedia[774:60b] -[CDVCommandQueue executePending] [Line 127] FAILED pluginJSON = [ "Device1738472658", "Device", "getDeviceInfo", [ ] ]
ERROR: Plugin 'NetworkStatus' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 2013-12-02 10:50:26.143 treemedia[774:60b] -[CDVCommandQueue executePending] [Line 127] FAILED pluginJSON = [ "NetworkStatus1738472659", "NetworkStatus", "getConnectionInfo", [ ] ]
错误:找不到插件“StatusBar”,或者不是 CDVPlugin。检查 config.xml 中的插件映射。2013-12-02 10:50:26.136 treemedia[774:60b] -[CDVCommandQueue executePending] [Line 127] FAILED pluginJSON = [“无效”,“状态栏”,“_ready”,[]]
错误:找不到插件“设备”,或者不是 CDVPlugin。检查 config.xml 中的插件映射。2013-12-02 10:50:26.140 treemedia[774:60b] -[CDVCommandQueue executePending] [Line 127] FAILED pluginJSON = [“Device1738472658”,“Device”,“getDeviceInfo”,[] ]
错误:找不到插件“NetworkStatus”,或者不是 CDVPlugin。检查 config.xml 中的插件映射。2013-12-02 10:50:26.143 treemedia[774:60b] -[CDVCommandQueue executePending] [Line 127] FAILED pluginJSON = [“NetworkStatus1738472659”, “NetworkStatus”, “getConnectionInfo”, [] ]
In order to run the app without errors, I have to remove the platform and plugin json file, then re-add the ios platform and rebuild. If I skip those steps and just rebuild, these errors occur every time.
为了无误地运行应用程序,我必须删除平台和插件 json 文件,然后重新添加 ios 平台并重建。如果我跳过这些步骤而只是重建,这些错误每次都会发生。
This has only started happening since updating Phonegap/Cordova to 3.2.0 from a slightly earlier version.
自从将 Phonegap/Cordova 从稍早的版本更新到 3.2.0 以来,这种情况才开始发生。
回答by bjunix
In XCode, goto Build Phases -> open the Compiled Sources dropdown. Click + and add the missing plugin .m file that should be in your Plugins directory (but is missing from the compiled sources).
在 XCode 中,转到 Build Phases -> 打开 Compiled Sources 下拉菜单。单击 + 并添加应该在您的 Plugins 目录中的缺少的插件 .m 文件(但在编译源中缺少)。
This solution came from another stack overflow answer, here: https://stackoverflow.com/a/21148428/80254
这个解决方案来自另一个堆栈溢出答案,在这里:https: //stackoverflow.com/a/21148428/80254
回答by bbodien
I seem to have resolved this by modifying the config.xml file that exists in the "www" subdirectory of the project.
我似乎通过修改项目“www”子目录中存在的 config.xml 文件解决了这个问题。
With a clean build from scratch, Cordova seems to generate the config.xml file under "platforms/ios" withthe plugin feature tags (perhaps inferring their use from the presence of the plugin files themselves), but on rebuilding then those get lost.
通过从头开始干净的构建,Cordova 似乎在“platforms/ios”下生成了带有插件功能标签的 config.xml 文件(可能是从插件文件本身的存在推断它们的使用),但是在重建时那些会丢失。
By having them explicitly defined in the www/config.xml path, the rebuilds work fine.
通过在 www/config.xml 路径中明确定义它们,重建工作正常。
回答by Stanislav Iegorov
Very straightforward solution that worked for me: downgrade Cordova CLI version to earliest one that doesn't erase ios.json during build.
对我有用的非常简单的解决方案:将 Cordova CLI 版本降级到在构建过程中不会删除 ios.json 的最早版本。
My case: CLI version was 5.4.1, upgraded to 6.3.1 - fail. Downgraded to 6.2.0 - OK
我的情况:CLI 版本是 5.4.1,升级到 6.3.1 - 失败。降级到 6.2.0 - 好的
One downside is that you need to test CLI versions manually.
一个缺点是您需要手动测试 CLI 版本。