How j2ObjC works

Fabrizio Cacciapuoti :

I am here to have some clarifications on how j2ObjC works. I've developed my own app on android and now I'm trying to get into the world of IOS with less problems as possible. I heard of j2objc and I would know it's mechanism before I could use it. I know that j2objc leaves the UI creation to the developer but how It works if I should try to convert a java file with declarations of Text views , Recycler views and their adapters, etc? It makes impossible to convert the entire file, deletes the problematic parts or maybe tries to find an equivalent of them? And finally, should i use it to convert all the Java files of the activities or maybe only the simplest java files (Like the ones with constructor's, getters and setters, etc). Thanks to everyone who will take some time to help me :)

tball :

+1 to Woodrow's answer as to how J2ObjC works. We chose to do source-to-source because when the project started, Apple seemed very intent on not allowing Java or Java-like languages on iOS: no GC or dynamic code execution, for example. To avoid any AppStore blocking, we generated source code that could be visually inspected for compliance, if necessary. It also helped that developers have an easier time finding and reporting compilation bugs when the output is another language, rather than object code.

I think the real question you're asking, though, is how useful would J2ObjC be in translating an existing Android app. The answer to that is "rarely", unfortunately. J2ObjC's first customer was Inbox by Gmail, which was already designed so that Java code could be shared by its server and Android client, then by its web client using GWT. None of its UI code was shared, but the app was still ~70% shared Java code when it released, since it was designed to share code from its beginning. Smaller apps written specifically for Android are likely to have very little shareable code, as the data models and business logic is embedded in classes that control the UI.

So if you have a smaller app, especially one where the business logic and data models are all kept on the server (or your app doesn't have a server component), then the best approach is a complete rewrite in iOS. That sounds difficult, but the hard part of designing the app is already done in your Android app.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=308251&siteId=1