What is the need of staging folder in Cordova 3.5.0 iOS application?
Asked Answered
H

3

10

We are working on a hybrid iOS application. Previously we were using Cordova 3.2.0 version. Recently we are under the process of upgrading our Cordova version to 3.5.0. After creating a new project with Cordova 3.5.0 and opening it with Xcode 5.1.1, we can see a new folder named "Staging" in the Xcode project structure (it's pretty strange for us).

In the root folder of project, there is no staging folder found. Below is the screenshot.

enter image description here

But after opening it with Xcode, the "www" folder and the "config.xml" are coming under staging directory instead of the root directory. Also, I can see two sets of www folder and config.xml file. The www folder & config.xml file which comes under root folder appears in red color (that may be because I have taken only the my_cordova_project --> platform --> ios directory and copied it to some other place. I am planning to commit only the ios folder to my versioning tool). I have simply deleted those two references.

enter image description here enter image description here

Could someone please explain me if this is an issue. Can I get the old Xcode project structure with Cordova 3.5.0 also? Please let me know in case of any clarifications.

Hire answered 25/8, 2014 at 14:33 Comment(0)
A
7

Sorry, I did not understand your question. Staging is simply a link folder to the ios-proj/www folder, and you can edit your code normally modifying the original.

In a multi-platform project "cordova platform add " will create a different project for each platform, in this case your editing should be done in the common code and sync sources through "cordova build" that will copy and compile code.

A similar question about the staging purpose: Purpose of Staging folder in PhoneGap 3.4? Only changes to index.html in this folder get recognized? enter image description here

Alcorn answered 25/8, 2014 at 16:8 Comment(14)
Thanks. But i am not clear. Could you please explain a little more. May be you cab give some examples or reference links.Hire
I have just added some explanation.Amphiaster
Seems like I am slowly understanding this. But not completely clear now. I have edited the question slightly to make things clear. Could you please tell me whether I am heading in a right direction or not. Suggest me if I should do any changes. Thank You.Hire
There is something wrong. Original www common code should be in the project. Follow these steps:Amphiaster
Can you please tell me which steps i need to follow. For your information, after creating the Cordova project using CLI, i want to keep the ios xcode project Alone. Other supporting Cordova related folders, I am storing somewhere in my locale and machine for futureHire
Sorry... I thing there is something wrong with the migration. Original www common code should be in the project, in fact it should be the source editing folder. Follow these steps: 1. execute: cordova create mobileBanking 2. replace source files in the www folder that has been created, or create a link to them, let's name it "original folder" 3. execute: cordova platform add ios, this will create the staging area 4. Open XCode 5. Do not edit the staging area, always the original folder 6. Always run "codova build" in order to syng from original folder to the stagingAmphiaster
Thanks a lot for this step wise explanation. It helps me.Hire
Added image with the final result.Amphiaster
Yes. I too got the similar structure like what you have in the screenshot. But if you see, there are two www folders. Could you explain why two www folders are required. Is not the staging --> www folder enough?Hire
Please clarify my above doubt.Hire
Original folder is the common source that builds (copy) to every platform, in this case ios but in a cross dev that could be several buildsAmphiaster
Yes. That point i understood. Thanks. But, still its unclear to me why should there be two www folders. Lets assume this is multi platform project with android being the other one. Could you explain this. And also why the same www directory at two places ?Hire
Please read: docs.phonegap.com/en/3.5.0/… chapters: Add platforms (WARNING MESSAGE explains about our problem) and "Using merges to Customize Each Platform", I think this is very explanatoryAmphiaster
it's very inefficient to run "cordova build" every time you do any changes (css, js, html) and re-run the xcode simulator.Felizio
S
5

I had the same problem understanding the relation of /www and /platforms/ios/www. I realized the former should contain the source common to all platforms and the latter should hold platform specific modifications. The Staging folder appearing in the Xcode project is a link to the latter folder. Modifying the content on the former folder and running the app seemed to have no effect - no modifications were seen.

The thing I was missing was that after the modifications I would still need to do the build on command line:

cordova build ios

After that the modifications in the common folder are copied to the platform specific folder(s) and running the project in Xcode shows the modified content.

Squamosal answered 17/12, 2014 at 19:57 Comment(1)
cordova prepare ios should be enough if one want to update www files only.Tgroup
P
1

You should sudo cordova build after making any changes, before you build/run in XCode.

This will cause Cordova to update the /staging folder with a "staged" (i.e. assembled for production) version of your assets that has some Cordova magic like device-specific plugins. Compare /staging to /www and you'll notice some additional files in the former.

Personate answered 26/4, 2015 at 4:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.