3

Possible Duplicate:
Technology to write iPhone, BlackBerry and Android phone at the same time?

Edit - guys, we need one more vote to close this. This question is a dup (read the comments)

I've heard that Apple banned such tools. Ok, so Apple lifted their ban in September. Still, the question holds - is there a sane way to develop apps to these two platforms without writing nearly everything twice?

Is there something I'm missing, or is the current state of affairs really that every company that develops a cross-platform legally has to maintain two code bases?

Community
  • 1
  • 1
ripper234
  • 222,824
  • 274
  • 634
  • 905
  • See also [What work has been done on cross-platform mobile development?](http://stackoverflow.com/questions/51988/what-work-has-been-done-on-cross-platform-mobile-development), [cross-platform development for mobile devices](http://stackoverflow.com/questions/2380196/cross-platform-development-for-mobile-devices), and [Crossplatform iPhone / Android code sharing](http://stackoverflow.com/questions/2380258/crossplatform-iphone-android-code-sharing) – Brad Larson Nov 05 '10 at 18:54
  • So many different formulations of the same pain :) – ripper234 Nov 05 '10 at 18:54

9 Answers9

6

Apple reversed their ban in early September after receiving some pressure from the FTC and EU. However, unless you plan on using a third-party tool such as Adobe Flash Pro CS5 (I believe you can create AIR apps that will run on Android this way, as well as the much publicized iOS functionality), you'll have to maintain two codebases anyway, as Android apps are written in Java and iOS apps in Objective-C, two vastly differently languages with vastly different APIs.

Spencer Hakim
  • 1,543
  • 9
  • 19
  • 1
    That's a bloody shame. Isn't there any product that will translate android/java code to Objective C? If so, then this is major open market niche ... I don't believe it is actually open. – ripper234 Nov 05 '10 at 18:38
  • If they had similar (read: the same) APIs it might be possible to write a translator similar to some ones I've seen for C# and VB (which both use the .NET Framework API, which is why that kind of translation is possible), but since they're just so different it isn't possible/worth the amount of effort required to get even a basic translator working. This is why a lot of cross-platform apps will have feature-set differences or release schedule differences (see: Facebook and Twitter apps for iOS and Android). – Spencer Hakim Nov 05 '10 at 18:42
  • I've a friend that developed a meta-language+meta-framework which compiles down to PHP+CakePHP, Ruby+Rails, or Python+django. So it's possible - but will probably be idiosyncratic, and might not cover the full scope of either API. – Iiridayn Nov 05 '10 at 18:51
5

You can always use standard HTML5 technologies to make a pure web app. Apple has two tracks for apps: native apps through the App Store written in Objective-C, or web apps that have only the restrictions of the underlying HTML5 technologies.

If you don't like pure web apps you can even merge the two and make a custom app that displays heavily customized web-like content in an embedded browser view (UIWebKit on iOS). Android and iOS web browsers frameworks are from WebKit and very close in features/appearance/conformance.

Instead of starting from a viewpoint of "I can't do X on Apple's closed iOS" start with "Can I do this in any supported application technology, even if its web-based or a web app hybrid, available across all platforms?"

ExitToShell
  • 460
  • 4
  • 14
  • This is a great approach to dealing with the issue. Additionally, you may want to look at the JQTouch library which extends JQuery functionality to emulate touch interface look and feel: http://www.jqtouch.com/ – DBQ Nov 05 '10 at 19:44
3

I've done some research on this recently and have found a few companies that can to do this for you.

  1. Appcelerator Titanium Mobile. They make a product that allows you to write your code in Javascript. I've found that the business logic, like networking, files, etc are write once, but the UI has quite a bit of if(android) else \iphone logic to get right. Apps will look native.
  2. FeedHenry. They are more of a HTML based solution, but have a broader support of devices. More than just iphone and android. The sdk is still pretty early, and work can only be done in their special ide that is web based.
  3. Phonegap. A javascript/css/html based framework that targets the iPhone, Android, and the Blackberry.

There are plusses and minuses to all of the solutions. Depending on your app's complexity, it may be a good decision to pick a platform like those to develop on. Coding an app could be much faster if the features they support are right for your app. Right now, it seems that they are all in early release phases and don't support a full toolkit that a developer would be used to, like a debugger, full IDE support, etc. Also, many of them build to a lowest common feature set, so you may not get all of the new release features as they come out, you would have to wait for a particular version of the platform to be released in order to have them.

Rob Howard
  • 41
  • 2
2

XMLVM: Android to iPhone

XMLVM can translate your Android code to Objective-C for iPhone. But as what I know you still need a Mac to compile the iPhone application.

Community
  • 1
  • 1
Jonas
  • 121,568
  • 97
  • 310
  • 388
2

Android has the NDK (native dev kit) to allow C and C++ code to be included in APKGs and called from Java via the JNI. Apple's toolchain will also deal with both; the code that will be different will be the platform interface code, mostly in Java on Android and ObjC on iOS.

This is only useful when the bulk of your application is in C or C++.

1

An alternate would be to go with MonoTouch and the upcoming MonoDroid, if everything works out you could basically code C# on all platforms including of course Win7 Mob.

It looks promising but haven't tried it myself yet.

AndersK
  • 35,813
  • 6
  • 60
  • 86
  • This could work, but the UI layer for your application would have to be platform-specific. However you could in theory share the back-end logic. – Joel Mueller Nov 05 '10 at 22:33
  • At least when it comes to MonoTouch it seems they support the GUI so if MonoDroid does the same then in theory it should be possible to reuse GUI code as well, but I know, that is wishful thinking at best but at least all code would be in C# code. – AndersK Nov 06 '10 at 01:48
0

In September, Apple lifted some of the restrictions in the iOS license that had made it difficult to do cross-platform development. See this press release. I'm not familiar with the details of the current license, but you can get a copy through their developer program.

Robert Calhoun
  • 4,823
  • 1
  • 38
  • 34
0

Another possibility that would be the Rhodes framework, if you like MVC, ORM, and Ruby.

-3

take a look at the System.getProperty() values with android the vendor shows as The Android Project. I haven't looked at the iPhone or the IPad since I don't have one but hopefully they have something changed for their's too. But this will only work with java that I know of.

Curtis
  • 101,612
  • 66
  • 270
  • 352