6 ms·
Ask HN: Best way to write an app for both Android and iOS?
I need to write an application that can run on both Android and Apple devices. At this point I have found a couple of solutions:
* 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.
- loudmax 16y agoIs there a particular reason why you can't or don't want to write it as a web page instead?
- mathrawka 16y agoAnd make a simple app that shows the application via a webview
- semanticist 16y agoThat's basically what PhoneGap does, although it also gives you JavaScript APIs to get at hardware features like the camera.
- MasterScrat 16y agoWe need to have access to the hardware. One of our features will be positioning using an advanced Wifi triangulation system.
- zackola 16y agoThe performance and feel of Google maps inside a WebView is terrible compared to the native maps applications. I recently attempted this and was incredibly disappointed. Decided eventually after fighting with Titanium before trying Phonegap to just do native versions.
- deweller 16y agoYou can check out Corona from Ansca as well: http://www.anscamobile.com/ http://www.anscamobile.com/ This IDE is geared for graphical oriented apps (games).
- MasterScrat 16y agoCorona looks good (even if we're not doing a game) but as students a free solution would be better.
- chopsueyar 16y agohttp://www.anscamobile.com/education/ http://www.anscamobile.com/education/ How about $49.
- cnkt 16y agoUse HTML+CSS+JS+PHP. Done.
- mohsen 16y agocome at me again bro
- adziki 16y agoI'm in the middle of trying to solve this challenge at work as well. I've bounced back and forth between a PhoneGap like solution, and doing it all in HTML with a web view wrapper. 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.)
- androidjim 16y agoDepends on what kind of app it is. 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.)
- semanticist 16y agoDepending on what you need your application to do, I would definitely go down the web app + PhoneGap route. 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-roundup 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.
- whatever_dude 16y agoHow is performance in the browser for PhoneGap applications? I'm not expecting anything native, but I tested some of the sample apps on my Android phone and they were... /underwhelming/ - clicking anything would take around 3 seconds just to switch to a new view, etc.
- semanticist 16y agoMy experience - at the moment - is specifically with jQTouch and iPhones. I've found that it performs well for simple views, but haven't tried anything complex. In general, PhoneGap's going to perform the same as if you tried it in the phone's browser. From some stuff I tried before, Android browser performance was noticeably slower than iPhone browser performance, but not so much as to make it unusable. I suspect it'll depend heavily on the device you're testing.
- parad0x 16y agoI totally agree with this approach. It's what we use, and it's really quick to get started with.
- torpor 16y agoI have written 7 apps for iPhone, 2 of which also run on Android. These two apps are however, primarily graphics apps, and its quite possible to share C++ code between the two platforms now. The whole GL ES engine is in C++, and for both Android and iPhone I have 'casing' code that provides the outer interface for the 3D engine .. This is pretty easy to do if you plan it right.
- willmacdonald 16y agoI would say use Appcelerator. It generates native apps for iOS and Android, so runs fast and can access all the hardware features, or at least more so than Phonegap can. I'm pretty certain Appcelerator can export to iOS, Android, WebOS, Windows7 and Blackberry (for a fee).
- fookyong 16y agoDepends on what kind of app I suppose, but if it is anything to do with 2D gaming, I'm totally loving Corona so far. 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/ http://www.anscamobile.com/corona/
- ConceptDog 16y agoVoted up for Corona. For 3D Games, look to Unity. I know people are have allot of success developing cross platform using it. But for 2D on mobile, Corona wins. 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.
- kwhinnery 16y agoI agree, we need to support unified projects.
- deleted 16y ago[deleted]
- pistoriusp 16y agoNothing beats native. 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 16y agoOne of the nice things about Appcelerator, as opposed to Corona, is that it's open source and they have guides (iOS: http://guides.appcelerator.com/en/module_ios.html http://guides.appcelerator.com/en/module_ios.html, Android: http://developer.appcelerator.com/guides/en/module_android.html http://developer.appcelerator.com/guides/en/module_android.h...) for extending the framework with native code. So, when you hit that inevitable wall, you can drop to native code and make it work on both platforms. I find the speed of development in Appcelerator quickly outweighs the drawbacks. That said, if you're developing a game, Corona is the better option. It's far more efficient in terms of FPS.
- jasongullickson 16y agoAgreed, 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 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.
- jakehow 16y agoHad the same experience with Appcelerator. Not knowing Objective-C it was a lot easier to get ideas into code quickly for prototyping, but when I ended up having to read all of their source and writing custom modules to get what I wanted done I decided it was not worth it. (Side benefit: this is how I got comfortable w/ Objective-C) 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.
- palguay 16y agoI created a website for toddlers in HTML5 +JS http://microangels.in http://microangels.in . The website works great in safari, firefox & chrome but when I tried to use phonegap the page would not show up. Debugging in phonegap is a pain and I did not find much help in documentation, mailing list or IRC . I ended up using the android webview + Jquery mobile and the app works great I will need to look at the iOS next. So I would say that go with html5 and the native webview and it should be easy to add in the parts that need to be written in Obj-c or java easily instead of trying to figure out the frameworks
- headhuntermdk 16y agoWrite everything twice.. Two separate codebases.. It's gonna suck but will at least give you the opportunity to deliver the best experience that your users expect from each platform
- tocomment 16y agoC++ on android? I hadn't heard of that.
- harph 16y agoNDK http://developer.android.com/sdk/ndk/index.html http://developer.android.com/sdk/ndk/index.html 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.
- pbreynolds 16y agoIf you want the best user (and developer) experience, write 2 different codebases and share graphical assets. 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 16y agoUI layout in code can be a pain because you can't see what you're doing until you do the compile-install-run which can be 30 seconds. That's a hefty amount of time if you're just tweaking one visual element and need to run through 1-10 possibilities.
- pbreynolds 16y agoNormally I would agree- ALL my iOS apps are done in Interface Builder. But if you add more than 50 PNGs to an Android/Eclipse project, the iteration cycle is well over a minute long compared to a 5 second recompile. That's not counting the slowness of the Android emulator (hardware was faster for debugging for me)
- tomaszkubacki 16y agomono ! - monotouch + monodroid => native toolkit and common base for businness logic
- kwhinnery 16y ago(Disclosure: I work for Appcelerator) I think you should take a look at Titanium from Appcelerator (http://www.appcelerator.com 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-javascript-code-after-app-is-compiled-using-titanium-mobile/4798547#4798547 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_ios.html http://guides.appcelerator.com/en/module_android.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 (community@appcelerator.com 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.
- clojurerocks 16y agoIve been going through the same issue and unfortunately there isnt a clear cut answer. Initially i was looking at phonegap, titanium and rhomobile. The problem with them is each has pros and cons and its very confusing to really understand what they are. Theres also fanboys of each which makes it even more difficult to understand what separates each. 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 16y agoJust to add that you cant write write native ui code in android with c++. The NDK is used for games and 3d applications or to access libraries that are coded in c++ already. 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 16y agoActually, as mentioned here already, you don't have to go native if you're writing a game. You can use Corona with great success, or Unity3D if you're going the 3D route.
- alexobenauer 16y agoIf you had to have the same code base for both, I would say use Sencha Touch and make native apps with just a web view in it for each. Sencha touch: http://www.sencha.com/products/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.
- xpaulbettsx 16y agoIt is more expensive because you'd have to license both, but you can also use MonoTouch and MonoDroid, and your core libraries (i.e. the .NET Framework) would be the same
- eapen 16y agoAdobe AIR/Flex has the option to export files to iOS, Android and Blackberry. I tried exporting a demo app to Android and it worked well. I havent tried the other platforms though. Obviously, I doubt the performance would be as good as a native app but a mobile application for a school which doesn't require a game engine, I would say Adobe AIR/Flex is the way to go. But since you require Wifi triangulation or GPS, this might not be an option.
- cpeterso 16y ago> I would say Adobe AIR/Flex is the way to go. But since you require Wifi triangulation or GPS, this might not be an option. 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/qs_as_geolocation_api.html http://www.adobe.com/devnet/air/quick_start_as/quickstarts/q...
- SeamusBrady 16y agoHow about Runtime Revolutions LiveCode? I have been a fan for years - never used the mobile version but they are a great little company and their other products rock. 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/ http://www.runrev.com/products/mobile-deployment/overview/
- pdebruic 16y agoWrite it in Smalltalk. Squeak runs on both platforms.
- sashthebash 16y agoShameless but on-topic plug: If you have content that needs to be displayed within both apps you could check out the flexible CMS my startup just created for mobile applications: http://storageroomapp.com http://storageroomapp.com. We are currently testing the system, let me know if I should invite you to the beta.
- robwgibbons 16y agoHTML + JavaScript + PhoneGap is a viable solution.