Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C to Java cross compiler [closed]

It is clear that cross compilers will not be allowed by the Apple App Store, so a developer will need to be familiar with Objective-C to create applications for the iPhone.

I was wondering, is there a cross compiler that will take Objective-C application code and rebuild it into a similar Java application that can be packaged for Android? That way, a developer could still learn just one language (obj-c) but put out applications on many devices.

I understand that the Java port would be less optimal than a natively coded application, but could conceivably save a developer some time.

Edit: Yes, the applications would be terrible. But would they not be as terrible as if they had been built by monotouch or the flash cross compiler? Couldn't those same methods be used that these cross compilers use?

like image 712
Mantas Vidutis Avatar asked May 07 '10 22:05

Mantas Vidutis


5 Answers

I've not heard of a cross-compiler that will do what you are asking. Even if one did exists, the bigger problem would be that the frameworks (UIKit, CoreAnimation, etc) are vastly different between the two platforms. Without some sort of common frameworks, all of the code interfacing with the frameworks will have to be reworked.

like image 163
highlycaffeinated Avatar answered Oct 25 '22 00:10

highlycaffeinated


This problem is solved with Apportable. It uses clang and Apple's Objective-c runtime and compiles for Android natively. It also bridges to that code with JNI in a nice way so it's accessible in Android. You don't have to convert to Java and there is no cost penalty in performance since it's compile for the native ARM architecture running on the device (it can even sometimes be faster than Dalvik/Java on the device). It also features a port of UIKit that maps everything fairly well.

like image 40
Zac Bowling Avatar answered Oct 25 '22 01:10

Zac Bowling


Not a chance. In general, translating from a low-level language like C to a (ever so slightly ) higher-level language like Java is going lead to some very sub-optimal code.

But that's not even the worst part - you'll need to translate between two extremely-different application models as well. You'd either have to re-implement most of Cocoa Touch as a shim over Android, or try to figure out what the iPhone app is actually doing and crank out equivalent Android idioms.

A much more likely path would be something like GNUstep, but I don't know if anyone is seriously looking at implementing the UIKit layer for GNUstep, and you'd end up with a native application at the end, rather than a Java app.

like image 27
Mark Bessey Avatar answered Oct 25 '22 01:10

Mark Bessey


There is one project, called XML Virtual Machine, that does sth similar to what you are asking. I was interested in that before i got to know the Objective-C. As far as I knew, cross compiling from Java to iPhone was possible(with some limitations). Project is still in development. You can checkout its webpage at XML VM webpage.

Maybe ppl from XML VM could answer your question(if they plan on creating cross compiling from Objective-C to Java).

But I still claim that making the application twice(for each platform using different languages and tools) would definitely give better results.

like image 32
krasnyk Avatar answered Oct 25 '22 01:10

krasnyk


Yes, there is an app which converts Objective-C to Java. You will still need to know some Java but it saves you a lot of time porting to Android. It comes with an Android compatibility project which you can add as a dependency in eclipse. It has customizable type and method mappings and you can specify method mappings using a template system.

Check it out here... O2J - Objective-C to Java Converter

Here's their how-to video... O2J Howto Video

like image 27
Cal Avatar answered Oct 25 '22 01:10

Cal