Twitter: raymondcamden


Address: Lafayette, LA, USA

Tip for PhoneGap Users - Modify the WWW template

01-24-2013 7,824 views Mobile 8 Comments

Now that I've gotten comfortable with PhoneGap's command line I'm finding myself much more productive when building quick demos. The previous link will tell you more, but as a quick example, this is how I'd quickly dump out an IOS project.

"ioscreate" is not the name of a PhoneGap binary, but simply a symbolic link to the create binary from the PhoneGap iOS directory.

I then CD into the folder, run "subl www" to open the www folder in Sublime, and run "cordova/build && cordova/emulate" to run the build and emulate commands. This pops open the new application in my iOS simulator.

All of this takes about 2 seconds and works great, except for one small nit. By default, the new project has this fancy HTML.

You can't see it - but the green "Device Is Ready" is pulsating. It's very hypnotic.

What this means is that I actually spend more time "cleaning" the HTML, JavaScript, and CSS then I do actually creating the new project.

Luckily there is a quick fix for this. Given your desired platform, go to where you installed PhoneGap and you will see a "bin" folder and beneath that, a "templates" folder. There should be one folder underneath it.

See the www folder? Just edit the contents within there to your liking and the next time you create a project, your modifications will be used. Here's my version.

Ok, that's kinda boring, but I've got a nice blank HTML, JS, and CSS file ready to go in my editor.

Related Blog Entries

8 Comments

  • Commented on 01-28-2013 at 2:37 AM
    That's not boring at all, that's really useful.

    I used the command line to build a test project last night to, I was pleasantly surprised at how quick the process was.

    Changing the template... and that "subl" shortcut is really useful!

    Thanks Ray.
  • Commented on 01-28-2013 at 5:18 AM
    You are most welcome.
  • Don #
    Commented on 02-02-2013 at 6:07 PM
    I'd like to get into mobile app dev space and am wondering how to get started, btw, I'm on Windows 7 OS platform and have not iPhone nor iPad nor smartphone. PhoneGap seems to be a development tool for mobile app, question, what iOS simulator have you used and like for Windows 7?

    Thanks.
  • Don #
    Commented on 02-03-2013 at 8:54 AM
    A side note, it would be extremely beneficial to be able to view blogs in chronological order (so that one can the progression of the subject matter).
  • Commented on 02-03-2013 at 9:04 AM
    View what blogs?
  • Commented on 02-04-2013 at 2:14 PM
    To your first question, Don, I've not used an iOS Simulator on Windows. I just use it on OSX. I've got both Windows and OSX.
  • Commented on 02-05-2013 at 1:33 PM
    Thanks for the great tips! The default template has bugged me a long time and now I can finally change it to something more ready for testing things. And the subl tip is awesome. Now I can just type
    subl .
    instead of
    open .
    and then dragging the directory from Finder to Sublime.
  • Commented on 02-05-2013 at 1:34 PM
    Glad to help. As for subl - that's the one thing holding me back from switching to Brackets full time. As soon as Brackets supports that, it will be my only editor.

Post Reply

Please refrain from posting large blocks of code as a comment. Use Pastebin or Gists instead. Text wrapped in asterisks (*) will be bold and text wrapped in underscores (_) will be italicized.

Leave this field empty