Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collaborate/Structure a large scale Phonegap project

My friend and I planned to start on a mobile Phonegap projects, which will cover iOS, Android, and Window Phone. It will require access to some native features like Camera Phone. It will also have to make some XHR server calls, which is done in CakePHP.

Now I am wondering how such a project is usually structured in Phonegap/ and what to Git commit.

Here are something I am considering:

1) We will need one repo for the server side stuff because this is relatively universal.

2) Should we keep all mobile apps in its separated Git repos? (so 1 for iOS, 1 for Android, 1 for Window Phone). This approach will have to maintain 3 separate www folder, each of will will be consisted of many html files.

3) Compact everything into one giant Git repo with a one-page HTML document index.html only. Everything else will be handled by javascript and device-related functions. (Though I don't know how to handle page transition, navigation, back button on this approach yet -- still learning)

I really admire this Wikimedia project done in Phonegap: https://github.com/wikimedia/WikipediaMobile. They keep everything in one giant repo and a universal www folder with separated device-related js files (like my approach 3). Though it's a little complicated for me to trace through how they've done their. If you happen to know of a case study broken down about WikipediaMobile, please let me know.

like image 517
Khoi Tran Avatar asked Nov 14 '22 00:11

Khoi Tran


1 Answers

The approach I recommend would be to have everything in one repository but break that down into a folder structure like:

- android
    [eclipse_project]

- ios
    [xcode_project]

- windows
    [vs_project]

- www

Each platform specific folder contains the native project for each platform (i.e. your Xcode project sits in the iOS folder, your Eclipse project sits in the Android folder) but the actual HTML/JS application is stored in the www folder.

In my opinion the web-application you build in a PhoneGap project should be entirely platform independent so there should only ever be one version. Given that the browsers across Android/iOS/Windows are pretty well standardised this shouldn't be too much of a problem so I can't see why separate JS files would be necessary. At any rate, if you need different behaviour per device you could identify the devices then handle it at a JavaScript-code/CSS level.

As @F481 hints at, whether or not you use PhoneGap Build will make a big difference. If you use PhoneGap build you won't need native projects (which is great if you aren't familiar with the native IDEs) so you'll only need a single folder for the web-application. I recommend you take a look!

I hope this answers your questions!

like image 128
Harry Avatar answered Nov 15 '22 23:11

Harry