Documentation on capacitor doesn't mention how to remove a platform.
And remove does not exist.
Does capacitor even support removing of a platform? How do I remove my platform without the obvious - manually deleting the folder
Unlike Cordova, native projects in Capacitor are a source asset instead of a build time asset.
You will have to delete the whole project manually and re add it with npx cap add.
Related
I have the HTML/JS/config.xml files of an app that was built using online phonegap build. How can I import these files into a project that I can work on with Eclipse/Phonegap CLI ?
The documentation here is all you need, just follow the steps.
http://cordova.apache.org/docs/en/4.0.0/guide_cli_index.md.html#The%20Command-Line%20Interface
First you will need to create a new project using your existing HTML/JS/CSS/icons
put your files in a folder, let's say c:\oldproject
create a new cordova project using the CLI and tell it to import your existing files (replace foldername, com.test.app and TestApp with proper values)
cordova create foldername com.test.app TestApp --copy-from=c:\oldproject
Replace phonegap.js reference with cordova.js
In index.html, replace the inclusion of phonegap.js with cordova.js (note that you may choose to use phonegap CLI instead of cordova CLI to create/build the project, in that case, you could continue to use phonegap.js)
Then put back the config and add plugins
replace the generated config.xml in the project with the one of your old project
If your config.xml contains plugins (lines begining with <gap:plugin) you will have to use the CLI to add each plugin.
For example if you have the line
<gap:plugin name="org.apache.cordova.file"
you would have to call
cordova plugin add org.apache.cordova.file
Then you have to add the android platform and build the project.
cordova platform add android
cordova build android
Now your project is ready to be imported in eclipse.
Please note that I don't really see any interest in using eclipse now that you can build projects using CLI. (I personnaly use a text editor that handles javascrit much better than eclipse and then do everything with the CLI).
Final warning
If you edit code in eclipse, you will be editing files in platforms/android/assets/www/, not in /www folder.
If you use the cli commands cordova build android or cordova prepare android, the CLI will take the content of the root www folder and put it in platforms/android/assets/www, so all your changes will be lost.
So if you choose to use eclipse to edit javascript/CSS, you will have to choose either save your changes to the root www folder before you use the CLI or stop using the CLI (so if you want to add a plugin you'd have to use plugman).
I was using build.phonegap.com in it's simplest way. That is: no sdk and no phonegap framework installed on my computer; no git or svn repository used. I just upload a zip with my html, css and js files.
But now I need to use the File plugin.
I found several posts (here and elsewhere) taking about using the CLI to add plugins and to build remotely since phonegap 3.0 (which doesn't use the config.xml to add plugins anymore, but instead it uses the CLI).
If you just used to upload a zip file to build.phonegap.com, are you now unable to use plugins since phonegap 3.0??
If that virtue is gone, what is now the simplest way for doing it? I currently use Aptana 3.0. Do I have to install Eclipse and install the phonegap framework? Do I have to create git of svn repository? Is that now the simplest way for using plugins in the cloud-based build service?
Is there a way to use the build.phonegap.com service with phonegap 2.x?? I have not found it yet.
This is taking me out of schedule for the imminent delivery of an ongoing project.
Please advise.
Put the config.xml in the www directory. And then upload only www.zip on build.phone.com.
In phonegap 2.x plugins like File were part of the core, so there was no need to include them through the config.xml file.
In phonegap 3.x every plugin has to be included through the config.xml file. BUT for plugins to work, the root index.html header must have a
<script src="phonegap.js"></script>
phonegap.js is provided (kind of injected) by the build.phonegap.com service, so I don't have to have it on my source code.
The script tag was the only thing I was missing.
Once I create my Phonegap project through the CLI with:
cordova create hello com.example.hello "HelloWorld"
add the android platform and import the project to my Eclipse, every time I run a cordova build android command, it undo/reverts the code that I changed on Eclipse, looks like it always gets reverted to the original project structure created by Cordova CLI, maybe I missed something in the documentation... any ideas?
UPDATE
Ok.. So the plan will be, I will develop my app using the root files, i.e., within hello/www/* (instead of the files within hello/platforms/android/assets/www/*) because Phonegap will override any changes to the ones for specific platforms as part of its build process. My development workflow then involves TextMate to edit HMTL/CSS/JS and then running cordova prepare under the project's folder in order to update the files in my Eclipse project.
Anyway.. just sharing my solution workaround to the cumbersome development process for Phonegap + Android because, IMHO, the documentation around this technology sucks...
I'm confused a bit by PhoneGap documentation:
Link 1 // How add plugins using "phonegap local plugin add" command
Link 2 // Tutorial about how to use camera module
Link 3 // PhoneGap Plugins
I've added camera module according (1). But in (2), there is information saying that I should add
<plugin name="Capture" value="org.apache.cordova.Capture"/>
to app/res/xml/plugins.xml and edit app/AndroidManifest.xml files too.
In reference to 3), also there is information that <plugin ... /> construction is obsolete and the developer should use <gap:plugin ... />, instead.
Referencing the latest API documentation:
There are two ways to approach this, first is by using Plugman, and the other is by using CLI. The CLI approach is much simpler.
The Plugman approach:
First, Plugman must be installed. Plugman is the plugin manager used by PhoneGap 3.4. To install Plugman, use the Node JS CLI and enter:
npm install -g plugman
Install the specific plugin using the plugman install command. For example plugman install --platform android --project platforms/android --plugin org.apache.cordova.device-motion. Be sure that the parameter for the --project option points directly to the platform folder, e.g. for Android, that's where the AndroidManifest.xml file is. This command automatically adds all references to the plugins to the pertinent xml files.
Be sure that your HTML file references phonegap.js by the line <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>.
Using CLI:
Go to your app directory and enter the plugin command in the CLI. For example:
phonegap plugin add org.apache.cordova.device-motion
installs the accelerometer plugin.
After the plugin has installed, it automatically updates all config.xml by adding the corresponding <feature> tags. Note that these updates only affect the platform-specific config.xml files. And so, the top-level config.xml file is not affected. You must manually copy and paste the <feature> tags to the top level config.xml. Otherwise, the plugins will be disabled when you run the app using phonegap run platform.
Take note that the corresponding <feature> tags can only be added to the corresponding config.xml files if your project is already ready to deploy in that specific platform.
If you are using phonegap 3.0 the latest as of this answer, you add plugins from the command line like so.
"phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git"
This is supposed to then add all the references to the plugin automatically now.
I have recently installed the AdMob plugin in my project.
To do this :
I opened NODE.js command prompt.
Navigated to the phonegap project.
Then typed this into the cmd : phonegap plugin add cordova-plugin-admobpro
This installed the plugin in the plugins directory in my phonegap project folder.
:)
Since Phonegap 3.0 you need to use 'plugman' to add plugins to a phonegap project.The important part is to set the 'path' to your project in the platform specific project folder created by phonegap. In iOS it would be something like: /Users/user1/Dev/helloworld-phonegap/platforms/ios.
Do the following to install the dialogs plugin for ios.
1) npm install -g plugman
2) plugman install --platform ios --project /path/to/my/platform/folder --plugin org.apache.cordova.dialogs
I
check the docs for more info: http://docs.phonegap.com/en/3.3.0/plugin_ref_plugman.md.html#Using%20Plugman%20to%20Manage%20Plugins
I'm trying to the the phoneGap framework as a library, there is something called CordovaLib which suppose to support it. here are the instractions http://docs.phonegap.com/en/2.0.0/guide_cordova-webview_ios.md.html
I followed the steps completely, however on step 23 I can't find the CordovaLib to add, and if I skip it I can't import the CDVViewController.
It looks like a basic Xcode configuration issue, Can anyone help me with that?
[Update] i've installed 1.9.0 and it works fine. they did some changes in the way they link the Lib in 2.0.0 and change the instructions accordingly however it doesn't seem to work.
I have had trouble with adding the target dependency as well.
One possible workaround is to open the CordovaLib project and build. This will create the CordovaLib.a library that you need to replace the pre 2.0 framework. You can then copy that library into your project and add it as a library dependency in the build phase area.