在 Xcode 中构建自定义插件时找不到插件错误

Plugin not found error building a custom plugin in Xcode

我是 phonegap 的新手,正在尝试尽可能多地学习。我按照 this tutorial 为 iOS 构建原生自定义插件,但是当我在 Xcode 上构建我的项目时,它给了我以下信息:

ERROR: Plugin 'FileWriter' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2015-10-02 22:10:07.168 MyCPlug[2673:196404] -[CDVCommandQueue executePending] [Line 159] FAILED
pluginJSON = ["FileWriter247765134","FileWriter","cordovaGetFileContents",[]]

我已经跟踪了每一个细节并尝试了多次,但我没有成功。

@哈桑,
正如我所说,Cordova/Phonegap 的插件是一个人可以承担的最艰巨的任务之一。部分原因是因为 Cordova/Phonegap 是一个移动的目标。

首先,它很丑。
例如,在过去两 (2) 周内,Apple 发布了针对移动设备的升级,从 8.x 到 iOS 9.0.1。不用说,这让很多开发人员措手不及。几天后 Phonegap Build,在周末,从 3.7.0 升级到 cli- 5.2.0。对于志愿者支持小组,我们完全没有意识到。直到 20 多个小时过去了,一位开发人员才发现它,主要是根据看到的模式。 (2 天后 Adobe/phonegap admitted to as much in this tweet)不用说这很烦人,但不是问题的根源。同样,它是一个移动的目标。

立即获取答案
首先,我将向您提供 link 我写的常见问题解答。在您应用解决方案(如下)后,我会阅读它,但不会遵循许多 link。该文档旨在供应用程序开发人员而非插件开发人员快速阅读。您会找到有用的信息,但不是您需要的答案。
Top Mistakes by Developers new to Cordova/Phonegap
我假设你已经读过这篇文章,无论如何我都包括 Plugin Development Guide

这是我的;这是预设答案。

来自 Phonegap Build 论坛,Petra Adds

I would add: without announcement, PGB changed the default PGB-version from 3.7.0 to cli-5.2.0. This causes all those who have not set 'phonegap-version' in config.xml to be confronted with the sudden need of splashscreen and whitelist plugins and additional whitelisting specifications in config and HTML.

Also, several plugins seem not to build correctly with cli-5.2.0, causing log file error messages about "Class ***.java".

FWIW:Phonegap 版本 admitted to as much in this tweet

快速修复 将此添加到您的 config.xml
<preference name="phonegap-version" value="3.7.0" />

否则Top Mistakes by Developers new to Cordova/Phonegap你已经命中:

  • #6 没有为您的编译器设置“phonegap 版本”
  • #7 没有为你的插件设置“版本”
  • #10 未在 config.xml 中添加新的“白名单”和“白名单插件”参数。

#6 和#7

With the CLI version, if you do not assign a version for your platform OR in 'Phonegap Build' if you do not set the phonegap-version in config.xml, YOU WILL GET THE LATEST VERSION. If you are lucky, your program just works as expected. If you are not lucky, you'll get a set of cascading errors.

Luckily for all of us, Holly Schinsky has written a nice blog post to explain it all:

Cordova/PhoneGap Version Confusion
http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/

对于#10

This relatively * NEW * requirement means – to access ANY website or resources on the web, you MUST use the whitelist and the whitelist plugin. This requirement goes into affect, if you are using cordova-android@4.0.0 or better; including cli-5.1.1. If however, your version is before 4.0.0, let's say 3.5.0 or 3.7.0, then you will not have to add the white-list requirement.

To be clear, the "whitelist" has been around for a bit, but the plugin and requirement is very new. As you would expect, when the "whitelist" was added, the de facto open-access feature was deprecated. Or said another way, the de facto open-access feature was planned and scheduled to be eliminated. This change marks a step in removal of the open-access feature.

In addition, the Content Security Policy (CSP) has caught numerous developers - because it was soooo poorly publicized. Depending on your use and the version of Phonegap you are using, the CSP needs to go in every single HTML page you used, just like you have to wait for 'deviceready'. However, there are cases where it is not needed at all. The documentation is confusing for some, please read it carefully. The documentation is buried in the bottom of many of the latest documentation pages.

相关链接

Phonegap Build Forum: Notes for upgrading to cli-5.1.1 on PGB and now required Whitelist