0

I am new to phonegap and trying to learn as much as I can. I followed this tutorial to build native custom plugin for iOS, but when I build my project on Xcode it gives me the following:

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",[]]

I've followed each and every bit of details and tried multiple times but I failed to succeed.

3
  • writing a plugin is the hardest thing to do with phonegap. If this is your goal, I would write some Apps first - so you understand the process. At the point, the ERROR indicates you do not know enough.
    – user3255670
    Oct 2, 2015 at 20:12
  • @JesseMonroy650 I didn't understand why this is happening. Is it related to the version of phonegap I am using or the new xcode does not support phonegap. I have gone through many tutorials and every tutorial is some what same and with every tutorial that I follow for custom plugin gives me the same error. I want to use some native code in my phonegap app. Oct 3, 2015 at 6:58
  • that tutorial is very old, read the official plugin development guide cordova.apache.org/docs/en/5.1.1/… Oct 5, 2015 at 9:53

1 Answer 1

0

@Hassan,
As I stated, a plugin for Cordova/Phonegap is one of the hardest tasks one can take on. Part of the reason is because Cordova/Phonegap is a moving target.

First, it'd Ugly.
For instance, over the last two (2) weeks, Apple release an upgrade for mobile devices from 8.x to iOS 9.0.1. Needless to say this caught many, many developers unprepared. Then a few days later Phonegap Build, over the weekend, did an *unannounced* upgrade from 3.7.0 to cli-5.2.0. For the volunteer support group we were completely unaware. It was not until 20+ hours had passed the one developer figured it out, mostly from the pattern seen. (2 days later Adobe/phonegap admitted to as much in this tweet) Needless to say this was annoying, but not the root of the problem. Again, it is a moving target.

NOW To get to your answser
First, I'm going to give you a link of an FAQ I wrote. After you apply the solution (below), I would read it, but not follow many of the links. The document is intended as a quick read for developer of Apps, not developers of plugins. You will find useful information, but not the answer you need.
Top Mistakes by Developers new to Cordova/Phonegap
I assume you have read this, am including anyway Plugin Development Guide

Here is what I have on this; this is a canned answer.

From the Phonegap Build Forum, 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 Build admitted to as much in this tweet

QUICK FIX Add this to your config.xml
<preference name="phonegap-version" value="3.7.0" />

Otherwise From Top Mistakes by Developers new to Cordova/Phonegap you have hit:

  • #6 Not setting the "phonegap version" for your compiler
  • #7 Not setting "version" for you plugins
  • #10 Not adding the new "white-list" and "white-list plugin" parameters in config.xml.

For #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/

For #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 [email protected] 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.

Related Links

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

5
  • my phonegap version is 5.3.1 and I applied your quick fix but it didn't help then I used phonegap platform add [email protected] but it didn't help either. It gives me same error Plugin 'FileWriter' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml Oct 4, 2015 at 11:53
  • @Hassan, the error you are getting should be unrelated to writing a plugin. You actually have a plugin missing. I would suggest removing you plugin for now and concentrate on the issue. If the error goes away, then it is an issue wit your plugin. If the error remains, I can help. But as I said, I my notes are developers of Apps, not developers of plugins.
    – user3255670
    Oct 4, 2015 at 17:15
  • The error only occurs when add custom plugin that is in this tutorial link Oct 4, 2015 at 17:45
  • this isn't an aswer, please @JesseMonroy650, stop pasting the same answer on every question Oct 5, 2015 at 9:50
  • @jcesarmobile, I agree with you that the use of this canned answer has demolished. As a matter of fact, it is likely to go on the back burner in the next few days. However, in this case, I've stated rather clearly the answer provide is unlikely to help. Even more, the OP appears to be doing little research and reading. I've got just more post on this subject. FWIW: Thanks for the feedback :-)
    – user3255670
    Oct 6, 2015 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.