Write an app without writing an app
16 December 2015, by James Griffiths
Here at Softwire, we’ve been busy building a mobile app for a chain of health clubs, and this is the first post in a four-part series about our experience and what we’ve learned. Watch this space for the next instalment, or follow us on twitter for updates!
We were recently asked by a large chain of health clubs to build an app for both iOS and Android platforms. We chose to build the app using Apache Cordova, rather than writing separate native applications. Why did we choose Cordova, and how do you get started with it on a new project?
The problem with native apps
At Softwire, we’re used to building native mobile phone apps, but building native apps comes with a number of difficulties:
- Each platform requires you to learn and use a specific programming language, development environment and set of libraries.
- You have to maintain a separate codebase for each platform and keep the code in sync between platforms.
- Each platform has its own quirks and bugs will typically be different in each platform.
All of this makes native development potentially more expensive and risky, and we’ve been interested in investigating other approaches for a while.
What’s the alternative?
The popular alternative to developing a native app is to develop a mobile-compatible website.
Web development is mature and well-supported with a good range of libraries and development environments, and is something we have a great deal of experience doing on other projects. When developing a website:
- You use the same programming language and libraries across all platforms.
- You only have one codebase.
- Each platform/browser will still have its own quirks and bugs but standardisation has been quickly improving over recent years (in mobile browsers particularly).
Wouldn’t it be good if we could get the ‘native’ feel of an app, but with the cross-platform advantages of web development?
This is the problem that Cordova is designed to solve.
Cordova takes a website and converts it into an app. It does this by building an app which comprises of:
- The files that make up your website
- A web browser that points at the local files of your website
How do I use it?
It’s pretty simple to get going with Cordova.
Once you’ve got a site you’d like to turn into an app, install Cordova from NPM and use the command-line interface to create a new app structure e.g.
cordova create MyFirstApp cd MyFirstApp cordova platform add android
…and you’ll have an working example app! You can now copy your built web application code into the new app’s www/ directory, rebuild, and your website should appear within the new app, all ready to go.
This will give you an app that works, but still feels distinctly like a web application, not a native mobile app. Next week I’ll write about how we made our app “feel like a native app”, rather than a website. Keep an eye on our blog for the next edition, or follow us on twitter for updates.