I am trying to build a Cordova app. All is set up fine, but I am confused now.
There is a www folder in the main folder which is displayed in Xcode. But there is a second in platforms/iOS. This folder is used when I am building the app.
Is that the way it should work? Or can I tell Xcode to take the other folder and not the www in root?
THANKS!
EDIT: And where to locate config.xml? Because in root the iOS App will not find any plugin e.g.
EDIT2: Got that with plugins! Have to install them over terminal
Yes this is a way Cordova is working.
The www in the main folder is the place where you have to implement you changes if you willing to support more then one platform. That folder copied to the platforms/ios/www each time when you run cordova prepare ios and this is actual folder which will be bundled with you iOS application. You you made changes in you main www folder and forget to run cordova prepare ios then you would not see you changes in you application if you run it. You have to run cordova prepare after making changes in the www in the main folder of you app.
Note: If you using cordova build or cordova run then you don't need to call cordova prepare, these commands will call it internally during the run.
As of Cordova 3.5 folder www in the Xcode which you see is same folder which is located in you main appication folder, and folder Staging->www in XCode is folder pointing to platforms/ios/www folder created by cordova prepare for you.
Before Cordova 3.4, www folder in XCode was pointing to platforms/ios/www folder.
I would recommend you made changes in www subfolder of you main folder and run cordova prepare\build\run to build/run your application if you plan to mainly work with HTML + JS or your application would support more then one platform. Otherwise, if you app is strictly iOS you could made you changes directly in Staging->www inside XCode and test you changes immidiately
You could start reading about development path with Cordova here: http://cordova.apache.org/docs/en/3.5.0/guide_overview_index.md.html#Overview_development_paths
More information about using Cordova CLI is here:
http://cordova.apache.org/docs/en/3.5.0/guide_cli_index.md.html#The%20Command-Line%20Interface for explanation of the workflow.
www folder in root level has html, javascript etc. When you build your code, same www folder for each platform will be created. So If you make any code changes in main www folder. You should rebuild the code for specific platform each time. Then only your changes in the main www will be applied in the platform specific www folder.
Related
I have created ios project with cordova 4.1
The problem that when I have removed some plugins , the ios folder refreshed and all my works lost .
Its create new www and ios folders , there is any way to recover my last ios and www folders ?
Create project expects a directory that does not exist.
See cordova create project look for path.
Quoting:
path: Directory which should not already exist. Cordova will create this directory. For more details on the directory structure, see below.
Every time I
Update my Cordova version
Update a Cordova platform version
Update a plugin
Add a plugin
To an existing app using node e.g.
cordova plugin add [some-plugin]
cordova platform update ios
etc
The update/add process always resets my [platform]/www/ folder to an empty project. I always take a backup before doing this, and put the www files back in. But there is always a conflict, or missed or forgotten files, which just increases the time to update.
This can't be right. Surely the Cordova update process can't really involve wiping out your existing project and starting again.
What am I doing wrong?
With a regular Cordova workflow you shouldn't be making any changes within the platforms directory. The platforms and plugins folders should be considered build artifacts and not checked in to source control. Cordova will automatically recreate them when needed.
When you run cordova prepare it will install all of the plugins you have listed in config.xml and copy the content of your root www folder to the platform www folder.
root/www files in the project does not work when I put it here
iOS platform project/www files in running.
but Cordova build can be reset and check this folder by deleting files?
Which is the correct folder for the project files? and how to prevent file loss during builder?
Thank You...
The correct folder for developing is the www in root.
If you don't want to use cordova build over and over again, you can symlink the content of this folder to the content of the platform www folder.
Or you can write a script, which is running before compiling. This script copies the content to the www folders.
Attention:
Don't copy the whole folder to the platform folders, because in the platform www are some specific scripts, depending of your OS.
I'm about to give up on trying to build PhoneGap ready apps using Visual Studio and go the Mac route. My only hesitation is all of my WebApis for accessing server data is developed using ASP.Net MVC WebApi (C#). I really do not want to jump from Mac for developing UI to Windows for developing WebApi.
Anyways, in researching PhoneGap 3.3 and using the CLI to establish the project structure, I discovered that a shared www folder is created where all of your Html, JS, and CSS code should reside. Each platform you add to your project (iOS, Android, etc) resides in a separate platforms folder:
Project Root Folder
|- platforms
|- iOS
| - www
|- android
| - www
|- www
|- css
|- js
|- index.html
The documentation says that you should not do any editing of files in any of the platforms www folders because the build process copies the files from the root www folder to each www folder in platforms.
The iOS folder contains xcodeProject file that opens the iOS platform's specific www folder (not the root folder). I understand that the www folder under iOS is specific for iOS platform. But this means you cannot use XCode to edit any of the files you see. Right now XCode is useless as an editor as it edits the wrong files.
How are we supposed to utilize Xcode against the root www folder? Thanks for your help.
I'll show you how my team works with Cordova on iOS. This may not be the way recommended from the documentation but it works (Besides, the documentation has never been reliable).
We develop an Android version side by side, for Android, following the documentation works quite well:
Copy files to www folder
Execute cordova build android
Copy the compiled app from platforms/android/bin folder
However, for iOS it gets tricky. As you mentioned above, there is the xcodeProject file. If you made any changes from xcode, executing cordova build ios will definitely overwrite those changes. We also found that running cordva build ios a second time will corrupt the config.xml file - invalidating all the plugins we need to run the app correctly (this is true as of 3.3.0).
So the recommended approach for our iOS team is to:
After creating the iOS project file (xcodeProject) using cordova build ios.
All changes to the HTML files should be made to the folder platforms/ios/www/.
The root folder www will not be touched.
Compiling the iOS IPA is done exclusively within Xcode.
This approach works for us since we compile our Android build file separately on a Windows PC. If you use one system for multiple platforms then it could be wiser to make all your changes to the root www and then creating a symbolic link at platforms/ios/www/ - still keeping Xcode for compiling iOS and cordova build ** command line for other platforms.
Hope this helps!
i've a cordova project created via cordova cli command.
i build the project for Android and iOS platform but... i copied the build project into respective workspace (eclipse/xcode) and i updated that single project.
Now i need to add a plugin.
The project into cordova project folder is now so outdate so i would add the plugin via cli and copy the plugin to the respective project.
I copied successfully the generated plugin into the android project, but i'm not able to do the same thing with iOS.
For example i added the console plugin for iOS
cordova plugin add org.apache.cordova.console
if i open and run the build project it work and i see my message in console, but if i try to copy the generated plugin into my existing project it doesn't work.
nobody could help me to understand how add manually a plugin into my existing project?
update
yes i know, i'll try to explain better
i have my cordova project under folder /Document/cordova
when i made an ios build via command line cordova put the built project under /Document/cordova/platforms/ios
well i copied the folder ios under /workspace/my-project-name
after some work under workspace i see that i need to add a cordova plugin.
i added the plugin via command line and it was added to /Document/cordova/platforms/ios
at this poin i have a project under /Document with plugin but asset outdated and one project updated without plugin under /workspace
i'm trying to copy from built project to /workspace project.
i copied
/workspace/my-project-name/my-project-name/Plugins
/workspace/my-project-name/my-project-name/config.xml
/workspace/my-project-name/www/plugins
/workspace/my-project-name/www/cordova.js
/workspace/my-project-name/www/cordova_plugins.js
but it doesn't work... i missed somethings?
After reading it several times I think I get more less the idea...
Well, I am not sure why do you want to copy the ios project outside the current location. I suppose you have a good reason to do it, however you can always tweak that project instead of going back and forward, cordova will not impact non cordova related files each time you run "cordova build".
Are you familiar with control versioning? Git, SVN, mercurial? If so it is simple just we which files were impacted once you add the plugin and copy those... If no, I suggest using control versioning anyways to help keep track of your code changes.
NOTE: Be aware if you build the cordova projet and then you just want to update the files noted above it is highly likely that it won't work, that is why you run "build" is not a simple file sync. I recommend taking the new cordova project with the plugin added and then just add you personal tweaks on the ios in the other folder. Or just tweak the ios folder inside platforms folder...
I hope you are doing for good reason. Anyway you are missing to copy below file to work
/workspace/my-project-name/my-project-name/platforms/ios/my-project-name/config.xml
Copying the cordova iOS platform folder is not a good idea. The reason is, cordova builds an Xcode project in the platform folder, and there is some sort of caching/built in references to absolute location of the original Xcode project. Therefore it would be unclear to you and to Xcode which file is being referenced from within Xcode. This may have caused some other unnoticed errors in the project as well. So therefore, instead of keeping original project path available along with the new path, I would recommend renaming the original project folder in order to remove the ambiguity. This way, you will assure that the right file versions are referenced.