How do cross-platform mobile app development frameworks work? - iphone

How are Rhodes, Phonegap, and Appcelerator able to take Javascript or Ruby, and compile them into binaries for app SDKs that normally require apps to be written in Obj-C, Java, and others?

Jeff Haynie, Appcelerator co-founder, explains how Titanium Mobile works here.

Phonegap uses the default browser rendering engine, and uses that to display your application.
The javascript is then handled by the native (compiled) part of the framework.
Appcelerator uses something simular, but compiles the whole application if i remember correctly.
MoSync uses a somewhat simular setup as javaME.
Rhodes uses local server. It uses this to communicate with the device.

A Javascript interpreter is built into the webkit browser engine, and the iPhone/iOS SDK gives enough access to this interpreter to run nearly an entire app written in Javascript, with just a tiny Objective C wrapper to start things up.
Android supports native ARM machine code though the NDK, so nearly any language with a compiler that can create a stand-alone ARM binary (but requiring little to no OS access) can be used as a library and accessed via the NDK interface from a Java app stub.

I've created an open source project http://propertycross.com that helps select a cross-platform mobile framework by showing the same application implemented with Sencha, Titanium, Xamarin and more. The project also includes details of how each framework works. It should help you compare end-user experience, code, developer experience and code shared between the various options.

Related

How to make shared logic usable for cross-platform native apps?

So I am currently using Xamarin for multi-platform mobile applications. I really like the way this works, and I want to improve my flow. My developers have said that they would be much faster when programming natively (i.e. Swift for iOS in XCode).
I have looked for a solution, where I can create a shared project and use it in native apps, but I have only found ways that involve programming in one language for all platforms.
Is there a way to create a shared project, which can be imported into a native application (or better, can be run together, like a shared project in Xamarin)?
The language for the shared code is not important, as long as it isn't slow.
My developers have said that they would be much faster when programming natively (i.e. Swift for iOS in XCode)
Swift can be used natively for iOS apps. RemObjects' Silver is supposed to make Swift ready for Android and .NET. I've never tested it. Try it out, it's free.
RoboVM can be used to write iOS apps in Java. I didn't try it out either.
Language mixing with Xamarin
In case you want to mix Swift code with C# code using Xamarin then you can bind Objective-C compatible Swift code and use it in iOS projects only. You are not able to execute Swift code on Android or Windows Phone! It's not possible to write platform independent business logic in Swift and and use it in a shared library or PCL with Xamarin.
You face the same restrictions for Java code on Android: You can bind JARs and use them in a Xamarin.Android project but you cannot use them on iOS or Windows Phone.
You are also unable to execute C# code in a Swift based app on iOS or in a Java based app on Android.
You can use native code in Xamarin apps via Binding Libraries. You cannot use Xamarin libraries in native apps.
If the goal is to use truly native tooling, in their standard languages (meaning not Xamarin) and still share code between iOS and Android, this can be achieved by writing your non-UI code in C++.
Here's a very interesting article about how Dropbox does exactly this.
C++ is natively supported on iOS and it is very easy to interface
between Objective-C and C++ using Objective-C++.
On Android, calling into C++ can be done through the NDK, which
reportedly is not a pleasure to use. Dropbox found Google’s meta-build
system gyp to work reasonably well. In addition, the Java Native
Interface is a pain you have to accept. But none of these issues is a
roadblock, and Steven expressed hope that Google or the community will
build better tooling support over time.
And here's a simple example of how to do this from another StackOverflow post

Can an android app be installed/converted to run on an iPhone?

I have an android project that targets Android 2.2 (developing in Eclipse). Exporting the android project to the Droid Incredible works perfectly. Is it possible to export the project to a file suitable for installing on an iphone? I know that most iPhone apps are developed using xCode, but I'm not sure if xCode packages into a .apk or other file format that's equivalent.
Thanks in advance.
Only if you write or port your own complete Dalvik VM (in Objective C or Javascript), plus developing the runtime support needed for any and all API calls that your app uses, and bundling all that with your app, as that would be the only way to run a regular Android project on an iPhone.
A non-trivial amount of work.
Completely rewriting the app in Objective C and Cocoa Touch would be magnitudes easier.
Not even remotely possible. Android and iOS are completely different environments. There are a few frameworks for developing applications that'll run on either, but the results often end up looking kind of weird on both platforms.
You cannot export an Android application and run it in an iPhone because the hardware/software stacks/APIs/etc. are different.
However, if you build an application using for instance PhoneGap (a HTML5 based application framework), it is possible to deploy it on different mobile platforms.
If you feel curious about multi-platform mobile frameworks (Android/iPhone) you may find this thread interesting.

Cross Platform Apps

I am not much clear with the "Cross Platform Apps." Can we really built up some apps which can run on iPhone/iPad , Android Phones/Tabs , Blackberry , Nokia (Any platform or more than one platform at least) ?
I have heard something like WAC , Titanium but really not clear with all these. Please help me out.
There are some good frameworks out there to build cross-platform mobile applications:
Titanium: It is a framework to build Android, IPhone (and BlackBerry, still in beta it seems) using javascript, that will compile to native applications for the platforms specified.
Rhodes: A ruby framework, that supports almost all the mobile platforms out there (recently they added support to WP7). It has an MVC structure, and can use RhoSync to synchronize the data to a server side application.
PhoneGap: Another javascript framework, but it supports more platforms than Titanium, because it doesn't compile to native applications, but it embeds a web application inside a native application (web apps/web views are supported in each platform, so it's easier to handle the portability this way).
The apps will have access to the hardware, like the camera/gps, through some generic apis.
In some case you can build specific native module to integrate them in just one application platform if you need to.
These frameworks are useful to build cross-platform application writing just one application, without having to write each single application with the platforms sdks.
They have some (or many) limitations. If your application are simple enough you can consider using one of those framework. But for more complex ones, sometimes, if you target only a couple of plaforms, it could take less time to build each one with native sdks individually than using one of this cross-platform framework, because of their limitations (I highly prefer using the Android SDK than using Titanium).

PhoneGap vs. Titanium

PhoneGap and Titanium allow you build native iPhone Apps based on HTML and JavaScript.
Has anyone gained experience with both? What are the differences?
There is a pretty lengthy discussion about PhoneGap VS Titanium (and Corona) on StackOverflow already that might be useful.
One of the big differences is that PhoneGap is MIT licensed and Titanium is (just recently changed) Apache licensed.
This article is a good summary of the practical and philosophical differences. Note its from an Appcelerator evangelist, but I still think its pretty impartial. In fact I think he shares Titanium more warts that I probably would :).
http://developer.appcelerator.com/blog/2012/05/comparing-titanium-and-phonegap.html
It's probably worth following the current Apple/Adobe spat, in which Mr Jobs has put the future of products that aren't written in language XYZ in the balance. OS 4 SDK states:
Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs. Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited).
I believe Titanium is affected by this.
Well..! this is not certain that which is better to implement the project.
Both technologies are new and having their pros & cons as well.
Titanium says to keep native environment with the help of java Script Based framework, on the other hand the phoneGap provides everything inside the WebView, you only need to put your web based project having index.html inside the WWW folder, found in the project directory structure of the Project.
So if you comfortable with Web Works, phoneGap is suitable in this case otherWise you should go with Titanium.Its easier to use and fully facilitated.
Unfortunately Titanium is not opensource anymore. You can develop apps freely but You have to buy Indie account to publish an app to appstore which cost some money.
PhoneGap is a free and open source framework that allows you to create mobile apps using web APIs for any platforms (iOS, android,windows, Blackberry etc) you think of.
Titanium: Is a cross platform, where in the code you write in JS and Titanium API's will be converted to native code and look and feel of the app will be same as native apps.
PhoneGap: Is a hybrid platform, where in you write the code using web technologies like JS, HTML and CSS. Which uses web views present in the native devices to render the UI. Look and feel is not same as native apps.

Language for phone software development

Exists an universal phone developement language?
I mean, for example, php or java or whatever
Edit : We have to develop a few phone applicatons, and we are looking for the best reusable language in differents devices (Blackberry, iPhone, Motorola, etc)
Java is as close as you'll come, but it's no where near universal (iPhone doesn't support it!)
Since iPhone's language isn't used by anything else either, it's pretty much a given that you won't find a universal solution.
Rhodes by Rhomobile is a Ruby framework for building cross-platform phone applications. It allows you to build a single application that works on all major smartphones: iPhone, BlackBerry, Windows Mobile, Symbian and Android. (The only obvious omissions seem to be OpenMoko and PalmOS/webOS, but all the phones you listed are supported.)
The way Rhodes works, is that you write your application in Ruby and your UI in HTML. A Ruby implementation, the Rhodes framework itself, your application scripts and your HTML files then get packaged up into what looks to the phone's operating system like a single native application. Rhodes then runs a webserver inside of the phone and serves the application from there, using the phone's builtin web browser UI component and a JavaScript UI library for making the web app look like a native app. (E.g. iUI for the iPhone.)
There was a nice introduction to Rhodes (with live coding) by the Rhomobile CEO at the Mountain West RubyConf 2009, the video is available at the Confreaks website.
Java (more specifically J2ME) will work on most phones. Googles Android and Blackberry development involves Java too. On Symbian-phones you can develop in C and there is an interpreter for python. If you are aiming for the iPhone market you have to stick to Objective-C and the Cocoa Touch framework.
There is no universal language, nor universal runtime that is supported by all of the major platforms. Two major players are Java on J2ME, BlackBerry and Android devices and Objective-C on the iPhone.
You might want to check out Symbian phone OS, it is intended as a common OS originally a joint collaboration between Nokia, Motorla and Ericsson. see: www.symbian.org/index.php
HTML + Javascript + CSS
PhoneGap!
It is the only cross platform mobile framework that I know of. Has feature support for iPhone, Android and Blackberry
http://phonegap.com/
Well!!! Most of the phones support java. What are you trying to do? Learn a new language?
Java is probably the closest you're going to find.
Even if you can do it, what good does it do to write a mediocre application that doesn't really take full advantage of whatever device it is on?
Bite the bullet and choose to do great implementations on a selected subset of mobile platforms.