PhoneGap makes mobile app development more accessible
At 4/19/2024
Editor’s note: This is a guest post from our friend Dan Moore. He recently wrote a book about PhoneGap’s new command line tools. I asked him to share what it was about these new tools got him so excited that he would do the most insane thing I can think of and become an author. Hope you enjoy. —Jason
Use of applications that run on your phone or tablet (aka apps) is growing rapidly. Building apps typically requires a specialized skill set–developers have to know languages like Objective C and Android Java. In addition, they need to have a design sense as well, because they are building user interfaces. Few developers have this combination of skills, and so those who do can charge for it.
But PhoneGap, a four year old project, now lets developers leverage standard web technologies such as CSS, HTML and JavaScript to build mobile applications. Designers who know CSS and HTML can create fantastic mobile friendly user interfaces (leveraging frameworks like Topcoat and Junior) and developers can focus on functionality and performance.
PhoneGap, and its open source foundation project Cordova, democratize the development of mobile applications. (PhoneGap is built on top of Cordova the same way Safari is built on WebKit, so there are many similarities between the projects.)
For end users, applications built using PhoneGap are indistinguishable from those built using native technologies. PhoneGap applications can access the camera, GPS and other device specific functionality. There is even a way (called ‘plugins’) for independent developers can write native code and access it from JavaScript.
PhoneGap Challenges
For most of the past four years, developers using PhoneGap faced a few problems when developing or maintaining PhoneGap applications. Among them:
- The PhoneGap framework moves fast, typically releasing a new version every month. Upgrades require understanding exactly what components beyond the standard JavaScript, HTML and CSS had changed.
- Plugins were not separate from look and feel or business logic.
- Every plugin had its own set of instructions for installation and/or upgrading.
- Supporting multiple device platforms with one set of JavaScript, HTML and CSS was a goal for PhoneGap development, but required either homegrown scripts or manual syncing between directories. Platform feature drift was difficult to avoid.
- Specific IDEs had to be set up for each supported platform.
All of these problems are tough enough for small applications, but for apps maintained for more than one release, the issues add up quickly.
CLI to the Rescue
Version 2.9 of PhoneGap, released in June of 2013, included a command line interface to manage applications. Instead of plugins being manually installed according to a README, standardized installation procedures are available. There’s a nascent plugin directory so that discovering a needed plugin no longer requires hunting through Google search results.
Instead of having to choose how to sync JavaScript, HTML and CSS, there is one location in a project for platform independent code, and one for platform specific code. Developers can develop outside of an IDE, in the web browser, using the web development technologies they are familiar with. There even is a system for calling scripts at various points of the application’s build cycle, so the CLI can be extended.
Developers still have to install and maintain device specific platform SDKs, but once they’ve done that once, they can add or remove a platform for a given project with a single command. And if a developer is just doing a quick prototype or can live with the (considerable) constraints, there is PhoneGap Build, a cloud service, which can build PhoneGap applications without requiring platform SDK installation.
With the PhoneGap/Cordova CLI, a developer can code and test a mobile application without running the device specific tools (like an IDE or ant script) even once. Of course, if an IDE makes a developer happier or more productive, they can use one for developing application code as well.
The CLI makes coping with change easier
The breakneck pace of PhoneGap development hasn’t changed, but the cost of upgrading has dramatically decreased. Instead of having to recreate platform environments entirely manually, or (more likely) simply not upgrading, most configuration has been pushed into standardized files. In some cases, upgrading can be as simple as running a few commands.
The command line interface opens up new worlds of automation, and continues PhoneGap’s march to democratize the mobile application development world.
Dan Moore is Director of Technology for 8z Real Estate, a Colorado and California real estate brokerage, and the author of “Developing Cross Platform Mobile Applications with Cordova CLI”