Cordova File plugin breaks my app - ios

I just installed the cordova file plugin and it completely breaks my application with this error:
ERROR: Method 'requestAllPaths:' not defined in Plugin 'File'
After googling for several variations of this topic I wasn't able to find anything that addresses this issue. Any ideas?
I am using Cordova 3.5.0 with the file plugin added like this:
cordova plugin add org.apache.cordova.file
I tried adding the optional configuration described in the readme on github but that didn't change anything.
This is the error code that I am getting when I run:
cordova run ios
[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
"File1936338184",
"File",
"requestAllPaths",
[
]
]
I am absolutely clueless as to why this is happening or where.

Somewhere in the App you are making a call to requestAllPaths.
As far as the File API documentation goes there is no such method as requestAllPaths
There is an API called requestFileSystem.
Hope it helps to debug your app
edit1:
You can have a look here for a similar issue.

Actually, the error happens if the plugin was already added to your project : in that case, it seems that the Cordova build process only updates the javascript interface but not the underlying native iOS sources, which explains the missing code :(
To fix it, you should remove the plugin beforing adding it :
cordova plugin rm org.apache.cordova.file
cordova plugin add org.apache.cordova.file
Be aware though that you might run in some additional issues : even if the files are properly updated in your platforms/ios/project_name/plugins directory, they might not be properly referenced in xcode => cf. cordova 3.4 with xcode 5.1 won´t build with latest file-transfer plugin
Hope it helps,
Cheers,
D.

Related

Ionic app loads using Ionic serve but not with Xcode

I'm currently stuck on a problem related to my Ionic project.
I have an Ionic project on GitHub which i've been working on in the past few weeks, i have a few Cordova plugins as part of the project.
When downloading the project from GitHub, i can run the app using Ionic Serve without a problem. However, when trying to setup the project for xCode to run on local device(s), i run into a multitude of errors
Some include:
When running ionic 'cordova platform add ios' the following error appears
Error: Could not install from "ios" as it does not contain a package.json file.
When trying to run 'ionic cordova run ios -l --external'
Error: Error: terminating with uncaught exception of type NSException
I have not yet tried to transfer my code into a new Ionic project, as i wish to see if my problem can be solved without that hassle.
View project code here: https://github.com/designsheikh/bitsandbobs.git
I figured it out. You have the exact same issue I've had with the android platform.
As I pointed it out in the comments, it is indeed caused by a "corrupted" project architecture.
How it happened
Initially, I had an issue with the cordova generated resources, somehow not being copied into the android platform directory. I tried plenty of things with the cordova-res CLI, including using the --copy and the --ios-project flags to force the copy to happen in the directory of my choice.
I couldn't manage to fix my issue, and then decided to rollback all my changes and start over on a clean project to try something else. Since then, I was not able to add the android platform anymore. Every single time, the following error was being thrown :
Error: Could not install from "android" as it does not contain a package.json file.
Explanation
With all my testing, I noticed that when using cordova to add the platform or copy the resources over, somehow, it had created the android platform in the wrong directory, at the root of my project instead of in the platforms folder. And that's where the issue comes from.
I can't explain it, but you will encounter this error every single time if you try to add a platform with cordova while having a folder with this platform name at the root of your project. I have no idea why this would prevent a platform from being added to the project, maybe this folder is used as a temp folder by the CLI.
Solution
The fix is to simply remove any ios or android directory at the root of your project.
The error will go away and you will be able to add the platform again.
#CodingJunkie
Regarding the Github repository you provided in your post, you will likely run into another error while trying to add the ios platform if you use cordova#>=9.0.0.
Using "requireCordovaModule" to load non-cordova module "xcode" is not supported.
Instead, add this module to your dependencies and use regular "require" to load it.
Check this issue#1033 for a workaround. However, it's not recommended to directly edit the plugin source code, you might want to look for another cordova Firebase plugin.
I also noticed you kinda mixed up cordova and capacitor in your project.
Make sure to use one or the other to avoid potential errors.
Hope this helped !
#Reqven
Thank you for your support! - i was sure that i had done this step while trying to fix the issue. It is such an absurd problem, it seems that there is a new project architecture as you mentioned which needs to be followed. I followed your steps with also one minor additional step as im working on the iIOS platform:
Delete iOS folder
cordova platform add ios
cordova prepare ios
ionic build
If step 2 throws an error causing the version not to be found or integrated into the project run - include '#latest' this also solved my problem

Cannot run iOS React Native app in Release Schema

When I switch my iOS project to the release schema (as described https://facebook.github.io/react-native/docs/running-on-device.html), I get this error:
2016-11-29 11:49:01.621 [fatal][tid:main] No script URL provided. Make sure the packager is running or you have embedded a JS bundle in your application bundle.unsanitizedScriptURLString:((null))
Do I need to create a static js bundle in production mode? The docs suggest that in earlier React Native docs, but I'm running React Native 0.35 (originally 0.30)
Finally resolved my issue. I was using a babel plugin to remove console.log statements as suggested by the docs. Removing the plugin got things working again
We solved this by unchecking "Run script only when installing" in XCode->Project Settings->Build Phases->Bundle React Native code and Images
Looks like Facebook is suggesting a babel-plugin-transform-remove-console solution that just does not work:
See issue https://github.com/facebook/react-native/issues/10412
I think something like this is badly needed to auto-remove console.log statements in a release build.

Cordova - 'Cordova/CDVURLRequestFilter.h' file not found

I have a problem with building iOS app with Cordova. I'm using Crosswalk with Cordova plugin. After running cordova build in terminal, I'm getting error message:
Plugins/cordova-plugin-whitelist/CDVNavigationWhitelistPlugin.h:23:9: fatal error:
'Cordova/CDVURLRequestFilter.h' file not found
#import <Cordova/CDVURLRequestFilter
Does anybody know how to fix that?
The reason was older version one of the plugins, that I've installed with Cordova-Crosswalk.
So it can be fixed in two ways - by updating everything (plugins etc.) or by simple installing again Cordova-Crosswalk via npm in different folder.

Cordova Build Error After Removing And Add The Same Plugin

I am getting build error while I am removing the plugin through Cordova CLI and again add the same plugin. Anybody can help me why I am getting error?
Thanks in Advance :)
Hi myself found the issue. While I am adding plugin to cordova iOS project, required frameworks also getting added to the XCode Project (Frameworks mentioned in plugin.xml). And while I am removing the plugin, the framework already added still remains in the XCode project navigator window. When again I am adding the plugin, cordova not adding the framework to this project hence getting the build error.
Solution
Run Cordova remove plugin through CLI
Manually remove the unused framework reference from the xcode project.
Add the plugin through Cordova CLI
I think this is either a Cordova or XCode bug. This error is inconsistent and its is happening sometimes. I got this error while developing & testing custom Cordova plugin.

Updating Cordova Plugin results in failed plugin

I'm running Cordova 3.4.1 and decided to update the one and only plugin I have, Console. I did based on the update to plugins dated April 23, 2014 ( http://cordova.apache.org/news/2014/04/23/plugins.release.html ).
Updating is done by first removing and then adding back the plugin. In other words:
cordova plugin rm org.apache.cordova.console
cordova plugin add org.apache.cordova.console
I then ran
cordova build
which does a lot of voodoo, after which I compiled and ran the app on iOS via Xcode.
The result is this fail: every time my code calls console.log I get this error in the XCode debugger output
CDVPlugin class CDVLogger (pluginName: Console) does not exist.
ERROR: Plugin 'Console' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
-[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
"INVALID",
"Console",
"logLevel",
[
"LOG",
"text i want to see"
]
]
Plainly the process of updating plugins is not working properly. How can fix this myself? And if I do will it effect any subsequent fix by the Cordova team?
FWIW: I repeated this process, tried an cordova platform update ios to no avail. I am loath to reinstall the entire thing given all the mysterious Xcode configuration and build stuff and hoping there's a simple fix...
I diff'ed the project against an earlier version I'd kept that worked properly and came up with this fix:
In Xcode, under your Phonegap or Cordova project, select
Target -> Build Phases -> Compile Sources
Add your plugin into the list there, in this case CVLogger.m located in your file structure under "Plugins".
After this, the project compiles without error and the console plugin works. No need to reinstall and reconfigure your entire project for this...

Resources