Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crossplatform iPhone / Android code sharing

Simply put: What is the most effective way to share / reuse code between iPhone and Android builds?

The two most common scenarios I think would be:

  1. Blank slate new project, knowing ahead of time there is a large chunk of reusable logic that needs to run on each device.
  2. Existing iPhone code base, porting of C, C++ and Objective-C to the Android NDK or otherwise.

Yes of course in a perfect world all apps would just plug into the magical cloud and all the reusable logic would be up in Google App Engine or some web services, but that is not the spirit of this question. After experiencing a port of iPhone to Android with no code reuse at all second-hand and seeing the pain that person had to endure, I'd like to know how other people are avoiding it.

like image 506
slf Avatar asked Mar 04 '10 15:03

slf


1 Answers

In my experience, you can use Android NDK to compile C and C++ , so if you use iPhone Obj-C++ (.mm) bindings for a C++/C engine in the iPhone, and in Android you use Java bindings to the same engine, It should be totally possible.

So C++/C engine ( almost same codebase for Android and iPhone ) + Thin bindings layer = Portable code.

like image 132
Goles Avatar answered Sep 30 '22 11:09

Goles