0

Does anyone have a sensible, clean method for having a single copy of the www asset folder for a phonegap app yet having an iOS and Android wrapper project?

I realise I could do some madness with symlinks, however it doesnt solve the swapping out of the cordova.js.

I also realise I could write a build script to xcopy and whatnot, thats probably what i'll have to do, but I was just wondering what solutions everyone else is using?

Andrew Bullock
  • 36,616
  • 34
  • 155
  • 231
  • I don't really have a wrapper for the project. What I usually do is version the www folder on the Subversion. Then I´ve got a folder inside the www with files that change depending if it´s iOS or Android, like the cordova.js or javascript config files. But aside that I don't really do much more. – reixa May 30 '13 at 12:15

2 Answers2

0

Edited to provide the cordova recommended approach:

As of Cordova 3.X, this workflow is supported with the new CLI tools. It allows you to create a Cordova project, edit the application assets in a single /www/ folder, and use the command line tools to propogate changes from your application-level /www/ into the individual platform-specific asset locations (like res/www/ for Android or /www/ for iOS.) I talked about this in this answer: Should a phonegap plugin be declared in the config.xml file?

My old answer, still relevant:

IBM Worklight provides this functionality. You create the application code in a /common/ folder, then you can place device specific code (if you need it) in the appropriate /Android/, /iPhone/, etc., folders. You can download the Developer Edition for free here: http://www-03.ibm.com/software/products/us/en/worklight/

I'm sure there are other products out there like IBM Worklight. I know that there are some NetBeans developers on the Cordova mailing list. I'm sure there are other consuming products (if you find any please edit this answer and list them!)

Community
  • 1
  • 1
MBillau
  • 5,366
  • 2
  • 28
  • 29
  • interesting, but not PhoneGap – Andrew Bullock May 30 '13 at 13:02
  • Actually, Worklight is built on top of Cordova. Cordova == PhoneGap. Worklight provides a lot of extra functionality that you probably wont need or use, but at its core it is just like using Eclipse to build PhoneGap apps. You have access to the same API's and everything. The only real downside I can see for you is that swapping out Cordova versions doesn't seem to be supported, but I'm sure you could hack through that. – MBillau May 30 '13 at 13:29
  • Sorry, but worklight is definitely not phonegap. For one, it's not even close to free. Two, phonegap is only one brick in the wall that is worklight. Overkill for someone who just wants to organize a simple phonegap app. – BinaryTox1n Oct 31 '13 at 14:03
  • Yup I'd agree. Worklight includes phonegap/cordova but provides a lot more functionality on top of it. I didn't mean to allude that they were equivalent. Worklight is just a product that uses Cordova, I'm sure there are a lot of other products that do the same. – MBillau Oct 31 '13 at 15:37
0

I had a common 'PhoneGap' folder and VS solution, and then in subdirectories 'iOS' and 'Android', a separate codebase for each platform, with all the relevant Xcode and Eclipse workspaces. That was any device-specific tweaks, or testing through emulators, could be done easily.

So far, straightforward.

I think I decided against symbolic links because of issues on OS X? Can't quite remember.

I was using TFS at the time, so I then wrote a console Application that would, on run, replicate your pending changes in TFS into whichever subdirectories you configured. This would mean all 3 codebases would update together. I decided not to automate this step, and let the user control if their changes are replicated by running the console app. The app was able to add, edit or delete existing files where required, and I also had a 'blacklist' of files to ignore, which included cordova.js.

It didn't take too long to knock up at all, the MSDN documentation is reasonable: http://msdn.microsoft.com/en-us/library/bb138973.aspx http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.workspace.pendadd.aspx

Here is a snippet:

var teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://dev:8080/tfs/MyCollection"));
versionControlServer = teamProjectCollection.GetService(typeof(VersionControlServer)) as VersionControlServer;
var pendingSets = versionControlServer.QueryPendingSets(new string[] { "$/" }, RecursionType.Full, workspaceInfo.Name, workspaceInfo.OwnerName);

if (pendingSets.Length > 0)
{
    var allPendingChanges = pendingSets[0].PendingChanges;
}

...

These are the namespaces:

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
Adam Marshall
  • 3,010
  • 9
  • 42
  • 80