Ask HN: Best way to write an app for both Android and iOS?
78 points| MasterScrat | 15 years ago | reply
* Use a framework such as Appcelerator Titanium or PhoneGap,
* Use C++, and then write the UI parts both in Java and Objective-C (as C++ can be run on both platform),
* Write everything twice...
What are your experiences and suggestions regarding this problem?
EDIT: I'm working on the mobile application for our school, we need more than a website because we want to do stuff like Wifi triangulation, maybe also AR.
[+] [-] kwhinnery|15 years ago|reply
I think you should take a look at Titanium from Appcelerator (http://www.appcelerator.com). For data-driven applications or native apps that don't require advanced 3D animations, it does a very good job providing a native user experience and access to device APIs. To describe how it works briefly, you write JavaScript code which maps to native APIs - that code is then included in a native app binary along with a JavaScript interpreter, and is interpreted at runtime on the device. A better/longer explanation is here:
http://stackoverflow.com/questions/4217551/what-happens-to-j...
Titanium has been deployed in over 12,000 apps in the Android Market/App Store, more than any other cross-platform framework (that we know of), so many developers have found success using it. That said, no technology is a silver bullet, so you'll need to take a look at your application and decide what is the right move for you.
If at some point while using Titanium, you discover you need more native functionality than we currently expose, it's easy to write a native extension (well, easy if you know Objective C and Java). Guides are located at:
http://guides.appcelerator.com/en/module_ios.html
http://guides.appcelerator.com/en/module_android.html
Despite the success we see every day by devs using the platform, Titanium can be a bit flaky at times - and I'm sorry to hear some folks have run into problems with their specific use cases. Feel free to reach out to me directly ([email protected] goes to my inbox) and I'd be happy to help out.
EDIT: We actually just demoed an AR app using the device camera, but the source isn't up yet (not sure why not, but it will be open source). If you follow our dev blog (developer.appcelerator.com) or keep up with our GitHub account (github.com/appcelerator), the source will pop up there.
[+] [-] pistoriusp|15 years ago|reply
I've tried Appcelerator and you'll get to a point near the end where you've got to do the other 80% of your application and the third party framework is going to fight you till completion, or some state of completion that you're ok with.
One of the problems is that the simplification also requires you to give up your power.
If you're doing a simple application then maybe a third party tool will help you, but in my experience I would rather work slowly and remain sane.
I would consider Appcelerator again if I needed to prototype something very quickly.
[+] [-] rufugee|15 years ago|reply
That said, if you're developing a game, Corona is the better option. It's far more efficient in terms of FPS.
[+] [-] jakehow|15 years ago|reply
If your app is brochureware or a simple web app port to mobile it probably works well. If you are pushing anywhere on the edges it starts to get difficult.
Organize your application really well and it will be easy to port between the two platforms for any models/libraries you write where the concepts are the same.
[+] [-] pseudonumos|15 years ago|reply
I recommend you analyze what features you're trying to leverage: camera, GPS, OpenGL ES/Rendering. Also, try and see what code you can reuse to be consistent across both platforms: the AR feature, wi-fi triangulation, and UI (UX will inherently have differences between iOS/Android).
My experiences with the camera include low-level image processing algorithms that 3rd party applications can't really optimize for. This is something from my own codebase that's fairly independent from everything else.
GPS/wi-fi triangulation is tricky because it's more understanding how iOS and Android track your location and maintain state. Whether or not you use a 3rd party application or your own code to parse it is up to you. As with a lot of things, the more you understand, the better decisions you can make ;).
Finally, UI (because I haven't done a lot of Open GL/rendering)... it's a pain to work with across different platforms, so leverage whatever you can to simplify this process. If all you're using 3rd party applications for is to translate iPhone UI to Android UI, go for it.
[+] [-] jasongullickson|15 years ago|reply
PhoneGap + jqtouch (or perhaps jquery mobile as it matures) is an awesome way to get going fast but that last mile can be torture, especially if you're working with an uncompromising customer/designer/etc.
At some point someone is going to throw on the brakes because "x doesn't y like an iPhone app" and then it gets ugly.
I think that you can do some very cool stuff using the "web app in a can" approach and I think it's appropriate for a lot of the typical "corporate"-type apps as long as you can manage expectations and stress the cross-platform angle (which can be almost zero-effort, check out https://build.phonegap.com/faq).
But pistoriusp is right, if you're breaking new ground then time invested in learning the native way is well spent.
[+] [-] pbreynolds|15 years ago|reply
Even though you could write portable C++, the API for getting to the hardware is going to be pretty different. I have worked on a project where we developed an app with identical look and feel on both Android and iOS simultaneously. The UI was basically completely custom (designed in Photoshop by a 3rd party).
My biggest advice is to do the Android UI layout IN CODE. The iOS version was completed in about 70% of the time of the Android project mostly because of the slowness of developing the UI with XML/Eclipse and Android's immature layout API.
[+] [-] temptemptemp13|15 years ago|reply
[+] [-] semanticist|15 years ago|reply
It's extremely easy to develop and test the app in a webkit browser, and then in the relevant phone simulators, and PhoneGap will very very easily wrap your web app into a native application - it also provides extra JavaScript APIs to access some hardware features, like the camera and geolocation and so on.
You can use any of the existing common mobile web app frameworks (I actually wrote about my experiences with several of them just last weekend: http://semantici.st/archives/223:ios-webapp-frameworks-round...), or do something entirely custom. You can certainly get a 'native enough' UI experience on iOS - I've not tried Android yet.
However, if you're planning to do anything that's really performance-limited this approach won't work. The performance is exactly as you'd get in a normal mobile web app, and if you're expecting to do, say, gaming or perhaps something complicated using the camera (like 'Layar' or 'Word Lens' type AR), you'll need to be writing native code.
[+] [-] matty|15 years ago|reply
[+] [-] whatever_dude|15 years ago|reply
[+] [-] parad0x|15 years ago|reply
[+] [-] fookyong|15 years ago|reply
I come from a web background (php/javascript) and I'm lost on Objective-C. But I picked up the basics of Lua in about a day and the next day had built a simple game. It's wickedly fast to get to grips with and the documentation is detailed and easy to read.
http://www.anscamobile.com/corona/
[+] [-] ConceptDog|15 years ago|reply
If they ever decided to go the Appcelerator work and come up with a deployment that also targets OSX and Windows at the same time, they'd absolutely rule.
[+] [-] unknown|15 years ago|reply
[deleted]
[+] [-] headhuntermdk|15 years ago|reply
[+] [-] eapen|15 years ago|reply
[+] [-] cpeterso|15 years ago|reply
Adobe AIR supports geolocation (using GPS and/or Wi-Fi) for both Android and iOS devices:
http://www.adobe.com/devnet/air/quick_start_as/quickstarts/q...
[+] [-] clojurerocks|15 years ago|reply
You can also go the jquery mobile/sencha touch/mobile rails route which is the direction i am going somewhat myself. These are actually pretty nice and fairly powerful for a basic application. Although jqeury mobile is newly developed as is mobile rails whereas sencha touch is pretty mature. Theres also jquery touch but i dont really know that much about it.
The question really comes down to what is the application doing. If you are doing a game you have to go native unless you can do something with html5 canvas. Also if you need to use something like gps or the camera or the accelarator you have to go either native or use phonegap, appcelarator or rhomobile as html5 through just a mobile browser cant give you access to the hardware.
What ive been ending up doing is just using straight jquery because im familiar with it and then seeing where my apps need to go.
[+] [-] clojurerocks|15 years ago|reply
Another question is will you also have to make your app availalable to blackberry or other devices such as an ipad. If so then phonegap rhomobile appcelarator and sencha touch, jqeury mobile yada yada yada might work best because theyre focus really is one having one codebase be able to be used on multiple platforms.
If you only have to target the iphone and android and you have a mac and want to learn how to code each then just go native. Ive played around with android myself so i understand why that would be needed as opposed to using html5. But if you havent done that then it wont make sense.
Oh good luck to you in your endeavor. Building mobile apps are fun but a pain in the ass right now because of all the fragmentation.
[+] [-] rufugee|15 years ago|reply
[+] [-] androidjim|15 years ago|reply
Is it a video game (use C++) or a web app (use PhoneGap), or a normal app (write everything twice, 'cause users expect platform specific look-and-feel.)
For what it's worth, two additional cross-platform frameworks you might want to look at are:
Corona (Lua-based, already used for hit iOS games.)
Unity3D (cross-platform 3D game engine.)
[+] [-] xpaulbettsx|15 years ago|reply
[+] [-] deweller|15 years ago|reply
This IDE is geared for graphical oriented apps (games).
[+] [-] MasterScrat|15 years ago|reply
[+] [-] sashthebash|15 years ago|reply
We are currently testing the system, let me know if I should invite you to the beta.
[+] [-] willmacdonald|15 years ago|reply
[+] [-] adziki|15 years ago|reply
The benefits of the HTML with webview are consistency, developing once, and being able to have a web app, blackberry app, webOS app as well.
However, if the app you're making needs to really leverage the functionality of the device, PhoneGap or making the device-specific logic in that native language is probably worth the extra effort (the trade off there is in efficiency of your app, and may be limited by the functionality of web pages on your mobile platforms.)
[+] [-] palguay|15 years ago|reply
[+] [-] SeamusBrady|15 years ago|reply
LiveCode is an offshoot of the HyperCard codebase and will run on everything from a toaster to your car. The apps seem pretty slick in the demos. Android support in in testing.
http://www.runrev.com/products/mobile-deployment/overview/
[+] [-] pdebruic|15 years ago|reply
[+] [-] alexobenauer|15 years ago|reply
Sencha touch: http://www.sencha.com/products/touch/
In my experience, I've found Sencha touch to be an incredible framework for developing native looking apps.
[+] [-] loudmax|15 years ago|reply
[+] [-] zackola|15 years ago|reply
[+] [-] MasterScrat|15 years ago|reply
[+] [-] mathrawka|15 years ago|reply
[+] [-] tocomment|15 years ago|reply
[+] [-] harph|15 years ago|reply
I'm playing with it at the moment. It might seem a bit frustrating first, with all those JNI naming conventions and getting it to integrate with Eclipse, but hopefully it's performance will make up for it.