Question

We have encountered quite a few problems with our versioning when it came to our new project, where we work with phonegap 3.2. I wanted to ask you what's the best way to have the data versioned, with the following requirements:

  • All developers have to change the www folder in the root directory in the project
  • Some developers also need to change the Java Files in the platforms/android/src folder
  • Some developers also need to change the Objective C code

Should there be 3 different repository Locations, one with the www, and one for each platform? Or should there be only one repository location where each developer checks out what he needs? Or should everyone have the whole project with all platform files in it?

The problems we encountered were mainly when platform code was changed through a cordova build and commited afterwoods. Also sometimes after you had checked out the whole project which was running fine on another computer, it wouldn't build anymore.

Any hints are appreciated

Was it helpful?

Solution

Currently Cordova support two official way of building their applications. 1. CLI based, where you work completely cross-platform and have to store only www and merges folder. Developers have assumption that you could use Cordova CLI on the new machine to setup your environment

cordova platform add android
cordova platform add ios
cordova plugin add org.apache.cordova.device

This workflow gives you benefit of having common codebase in www folder and you have to kepp platform-specific overrides for you CSS,JS or HTML files in merges/android or merges/ios subfolders, but you cannot have modify platform-specific code that way.

  1. Platform SDK development workflow. Where you create application using standard SDK tools for platform then add CordovaLib as dependency and embed WebView as needed. Then you use Eclipse/XCode for further development. If you have more then one project setup that way, you have to manually ensure that www folders in both projects remains in sync.

This workflow gives you benefit of having ability to use all platform functionality, but you have to manually sync contents of www folders, and somehow work with platform specific CSS/JS/HTML Note: Under supported I mean, this is two workflow which gives more attention from developers.

Now to your question - I propose you to have following workflow which is slightly modified version of CLI-based workflow. You have to store you www, merges folders and only parts of the platforms. Plugins folder is not stored. Since many parts content of platforms sub-folders are generated by Cordova CLI you have to fiddle with your .gitignore file.

Content of .gitignore

## Eclipse specific stuff.
.metadata/

## Android specific stuff
local.properties
/platforms/android/gen
/platforms/android/bin
/platforms/android/assets/www
/platforms/android/.metadata
/platforms/android/.staging/www
/platforms/android/.settings
platforms/android/CordovaLib/.settings/
/platforms/android/CordovaLib/bin
/platforms/android/CordovaLib/bin/proguard.txt
*.d
*.class 

## iOS specific stuff
platforms/ios/.staging/
platforms/ios/platform_www/
platforms/ios/<--projectname-->.xcodeproj/project.xcworkspace
platforms/ios/<--projectname-->.xcodeproj/xcuserdata
platforms/ios/www

## Exclude Plugins
# For iOS you have to exclude only this single folder.
platforms/ios/<--projectname-->/Plugins/
# For Android you have to manually exclude folders for each plugin provider.
# .java files for plugins stored based on plugin id. For example
# to exclude all plugins provided by Cordova add following line.
# Make sure that when you create project you specify project ID 
# as com.yourcompany.yourapp that way your code will be in
# platforms/android/src/com/yourcompany/yourapp and separated from 
# plugins
platforms/android/src/org/apache/cordova/
# For example to exclude plugins provided by BlackBerry 
# add line 
# platforms/android/src/come/blackberry/

Now when you setup new project you should checkout source code and run following commands:

# Create local.properties file which is required for build
cordova platform update android 
# Or manually create local.properties with content below
# sdk.dir=C:\\adt\\sdk

# Add plugins
cordova plugin add org.apache.cordova.device
cordova plugin add org.apache.cordova.vibration
# ... and other plugins

After you setup project that way you able to do take best from both-worlds. You could do quick testing in the browser using cordova serve, you could do heavy-lifting using Android/iOS SDK if needed. If you keep you changes to Cordova codebase to minimum and use plugins to extend platform for you need whenether possible you could even update platforms to newer version of Cordova when they will be released.

Hopefully this you would be able to select method which will work best for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top