17

What's a good directory structure for a single source repository that holds both Android and iOS versions of a phonegap project? I'm okay using sym-links since I don't expect any development to happen on PCs. (But if there's a clean way to do it without, I'm all ears, since git and symlinks on PCs are a nightmare.) I've tried this:

www/
    index.html
    js/ *.js
    xpjs-ios/ *.js
    xpjs-android/ *.js
    css/ *.css
    html/ *.html  (all other files)

android/
        (lots of java and config files)
android/assets/www/index.html -> www/index.html
                   js -> www/js
                   xpjs -> www/xpjs-android
                   html -> www/html
                   css -> www/css
ios/
    (xcode config and such)
ios/www/index.html -> www/index.html
        js -> www/js
        xpjs -> www/xpjs-ios
        html -> www/html
        css -> www/css

Then I point xcode at the ios/www directory, and eclipse at the android/www directory. For platform-specific javascript, the html files refer to xpjs/phonegap.js and xpjs/my-quirks.js and get either the android or ios versions of those files.

This all seems like it should work, but xcode4 doesn't seem to deal with symlinks. If I open one of the source files in the xcode editor, it reads fine, but when I try to save it it says something like

The document "index.html" could not be saved.  It does not exist.

and the app when I try to run it fails with

ERROR: Start page 'www/index.html' was not found.

Surely somebody's figured this out.

Leopd
  • 41,333
  • 31
  • 129
  • 167

2 Answers2

4

there's a writeup (looks like a first pass) on the phonegap wiki that explains how to use a git submodule. to supplement that entry, i also did a writeup on using the svn:externals property. my only thought on symlinks is that it's something people have to setup as opposed to getting them intrinsically from the source control repository. not really a problem, but it is a logistic to the setup when you switch computers or get additional devs on a project. i'll be taking the svn:externals route until i find something better.

pinkeerach
  • 408
  • 9
  • 19
  • yeah if i had more experience w/git, i would elaborate. would love to hear how this works out. i'm proving out the svn side of things right now. – pinkeerach Sep 19 '11 at 16:05
  • 1
    I'm not marking the answer as accepted because I would really prefer a solution by configuring xcode & eclipse. Git is enough of a challenge for many that I'd rather not introduce another complexity for this project. – Leopd Sep 19 '11 at 16:46
  • 1
    i think its a fair comment though, in isolation i can see how a client side solution might be a bit easier, its usually in the realm you understand. Try having a team of 8 developers, some on windows and some on Macs and the source control solution becomes a whole lot more appealing – Matt Nov 04 '12 at 21:41
4

Its actually quite easy with Git and Submodules. The phonegap wiki referenced above is indeed a bit slim so I actually went ahead and implemented a solution that configures xcode & eclipse project.

See the link on my blog post: Phonegap project structure using git submodules

If you don't want to use Git submodules, there is a Symlink solution as well which doesn't care if you use Git or SVN.

http://www.tricedesigns.com/2012/02/16/linked-source-files-across-phonegap-projects-on-osx/

Leopd
  • 41,333
  • 31
  • 129
  • 167