I am running Cordova 2.9.1 for iOS. When I run my app in the browser, the console says I am missing cordova_plugins.js.
What is that? How do I get it?
Is that the reason none of my plugins are working at all?
Thanks!
Have you added the "browser" platform to your Cordova project?
cordova platform add browser
After which, you need to build the Cordova project:
cordova build browser
You'll notice the platforms/browser/www folder exists and contains a cordova_plugins.js file.
At this point, you need to "serve" files to your web browser from that folder (to test your app using a web browser). I use Grunt and the NodeStatic task for this purpose.
Hope this helps! Let me know if you have any questions, take care.
Related
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
Absolutely new to Cordova. These are the steps I've done:
Checked out an existing project
run cordova build ios
The above generates this build error:
(node:10242) UnhandledPromiseRejectionWarning: Error [ERR_UNHANDLED_ERROR]: Unhandled error. (The platform "ios" does not appear to be a valid cordova platform. It is missing API.js. ios not supported.)
I've Googled for a solution to the above and the general consensus seems to be to remove and then add the iOS platform.
Now there's a problem with that. Looking through the commit history, I can see that there have been code changes done to files within the platforms directory so I can't just remove it, or...
Question 1)
Can I?
Question 2)
Is it right to make code changes within the platforms directory? Because it seems like those are generated directories.
Question 3)
Why is it that when I open the Xcode project under platforms/ios, I am able to build/run it fine despite the Cordova CLI error above?
it's not right to manually edit the platform files. And some manual changes might make the project not build, so might be related to the manual changes somebody did. So if you don't want to risk to remove the platform, continue building from Xcode
from root www to platforms/ios is transferred by cordova commands such us cordova prepare ios or cordova build ios or cordova run ios.
So if you can't do a cordova prepare ios because of that error you can try a few things.
Copy your files from www to platforms/ios without replacing the whole folder, just the duplicate files. cordova prepare ios is not just a copy, it's also does some modifications/aditions, but if you don't remove existing files it might work.
Create a new project and copy the platforms/ios/cordova to your own project and see if that fixes the mentioned problem, as that's where the Api.js file is.
Downgrade the Cordova CLI, try to latest 7.x.x and if it doesn't work, try with latest 6.x.x, one of those won't require the Api.js as it relatively new.
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.
I am new to phonegap.
Using phonegap app I have created new project.
Now I like to use this project in xcode (7.2.1) is it possible?
What is the best way to develop app in phonegap for various plugin ,I was googled and heard about coredova but can't understand exact needed .
For IOS Try this to add any new Plugin.
Go to your Created Project Directory in Mac CLI.
Then do this.
If you haven't added IOS Platform then run below command.
cordova platform add ios
Then build your whole project with below command.
cordova prepare ios
Then to add plugin run below command.
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
Here take whatever plugin you want to install.
Make sure you connected with internet while installing plugin.
Now I like to use this project in xCode (7.2.1) is it possible?*
Yes it is possible, Read this article
What is the best way to develop app in phonegap for various plugin
I am assuming you are asking how to add different plugins?
Create your APP with the PhoneGap Interface (You already did)
Go to the www folder where you stored the PG build files and look for your config.xml, then you will see a section where a few plugins already exists. You can add additional ones by just simply copying and pasting the below XML syntax (Battery Status Plugin), example:
<plugin name="cordova-plugin-battery-status" spec="1.1.0" source="pgb" />
Reference this article for a comprehensive list of PhoneGap's plugins:
https://build.phonegap.com/plugins
Alternatively, you can add them through the Command Line interface (See the first answer to your question)
How do I prevent external links from opening in the in-app browser in apps built with Meteor for iOS? I want them to open in Safari instead.
You'll need to download and install an apache cordova plugin to add this functionality into your meteor ios app.
Simply run this command into your terminal
meteor add cordova:cordova-plugin-inappbrowser#https://github.com/apache/cordova-plugin-inappbrowser/tarball/ba7cbe58d5812b51c3ece1
(here is a ref to the tarball/ba7cbe58d5812b51c3ece1) (use the latest commit to master branch)
Then simply add this into your meteor template to launch the system default browser app with the external link:
<a href="" onclick="window.open('http://www.example-url.com', '_system');">
Hope this helps!
</a>
Run:
meteor run ios-device
(select your trusty simulator and test her out)
Nick's answer to use the inappbrowser Cordova plugin is sound, but with the error you're seeing, make sure you're providing a full commit hash URL for the meteor tool/build to resolve. At the time of this writing, the correct Terminal command to use the latest commit is:
meteor add cordova:cordova-plugin-inappbrowser#https://github.com/apache/cordova-plugin-inappbrowser/tarball/bc9036d90a1f3f2220b5fc29b77cf2405e7fd781
The remaining steps are the same; use the _system target in your project's code for the link:
Open
Then kick off a meteor build for your desired mobile platform and Cordova should apply the plugin without issue. Verified these steps work on Meteor 1.2.1.