Why do I have to choose a device in phonegap when it's supposed to be one code base for many platforms?

Go To StackoverFlow.com


My question pertaining to phonegap is simple and yet I cannot find an answer.

I'm about to get started on writing a simple phone app that I can deploy to many platforms, which Phonegap claims to be able to do.

If I am writing one codebase and compiling to many apps, why do I have to choose a platform to code against? Surely I write generic code and compile it afterwards for each device?

2012-04-04 17:54
by NibblyPig


If you build your project, phonegap needs to know for which platform it must link it's binaries. That way you get a working package for your testing platform, so you can run and debug it before publishing.

Once the application is finished you strip the platform dependent binaries and upload your source to their webservice.

The webservice will then build the binaries for other platforms.

2012-04-04 18:02
by huysentruitw
I see, can you not build it platform-independent from the start? Seems bad to dev something you later have to refactor. Or are the platform dependent libraries interchangable - NibblyPig 2012-04-04 18:06
What you want is HTML5 with CSS3 and JS with all requested HTML5 features implemented. Today this does not exist, that's why Phonegap was born.

With phonegap, you still create a HTML5/CSS3 project but phonegap adds a per platform library to extend its functionality. Then you need to build the project in a kind of full-screen browser app.

What you see if you start a phonegap app is a fullscreen browser that browses to embedded HTML5 pages and javascript is extended with functions from a per platform library - huysentruitw 2012-04-04 18:11

I see, thanks. If I may ask just one more question - what platform should I choose? If everything is being written in HTML and Javascript, I guess Android would be the best since I have an android phone and it requires no registration. However I'm a C# developer, so perhaps I should go windows phone and choose Visual Studio? What do you think - NibblyPig 2012-04-04 18:13
If you prefer visual studio, I would create it in visual studio. You'll have to install the Windows Phone SDK which comes with a very good and fast emulator. One drawback of using the Windows Phone emulator is that you can't see the camera stream - huysentruitw 2012-04-04 18:16
Cool, thanks for your help - NibblyPig 2012-04-04 18:35