Tom Schreck
Tom Schreck

Reputation: 5287

PhoneGap 3.3 project structure and editing code

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.

Upvotes: 1

Views: 1546

Answers (1)

James Wong
James Wong

Reputation: 4619

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!

Upvotes: 2

Related Questions