Techie
Techie

Reputation: 45124

How should I do the platform specific code managements(SVN) for hybrid mobile apps?

I'm developing hybrid mobile application using PhoneGap & Titanium for Android, iOS and Windows mobile platforms. The application is relatively big and contains platform specific code due to it's nature.

As an example assume that there is a file called main.js. Should the main.js contain code belongs to all three platforms and use commenting when building application for each platform. When I'm building for Android comment out the code related to iOS and vice verse.

How should I do the code managements in SVN?

Upvotes: 2

Views: 4563

Answers (2)

Amar1989
Amar1989

Reputation: 512

Dont write redundant or comment and uncomment code, use cordova device plugin and check for device platform and write there if something platform specific.

example:

     if ( device.platform == 'android' || device.platform == 'Android' ){
     // write here android specific code
      }

Upvotes: 1

Raymond Camden
Raymond Camden

Reputation: 10857

Your question is a bit awkward. Your title talks about using SVN, which provides source code management for versioning, etc, but your question asks about platform specific code which is a bit different.

If you focus on the aspect of handling platform specific code, you've got a few ways to handle it in PhoneGap/Cordova. (I can't speak for Titanium.)

  1. You can use merges to automatically modify code on a per platform basis. See the docs here (way towards the bottom) - http://cordova.apache.org/docs/en/4.0.0/guide_cli_index.md.html#The%20Command-Line%20Interface

  2. You could use Device plugin (http://plugins.cordova.io/#/package/org.apache.cordova.device) to sniff the device and do something specific per platform.

  3. You could use hooks to modify the code per platform too. Merges is simpler, but hooks give you more power.

Update

Phonegap merge directories - assets not being merged

Upvotes: 2

Related Questions