跨平台的iPhone / Android的code共享 [英] Crossplatform iPhone / Android code sharing

查看:165
本文介绍了跨平台的iPhone / Android的code共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简而言之:什么是分享最有效的方法/ iPhone和Android之间的重用code建立

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. 在空白的石板新的项目,提前知道有一大块可重复使用的逻辑需要每个设备上运行。
  2. 在现有的iPhone code群,C,C ++和Objective-C的移植到的Andr​​oid NDK 或以其他方式。
  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.

是的,当然在一个完美的世界上所有的应用程序将只插入到神奇的云,所有的可重复使用的逻辑,将在谷歌应用程序引擎或某些网络服务,而不是这个问题的精神。在经历了iPhone的一个端口到Android用在所有的二手无code重用,看到那人不得不忍受的痛苦,我想知道别人是怎么避开它。

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.

推荐答案

在我的经验中,可以使用的Andr​​oid NDK编译C和C ++,所以如果你使用的是C ++ / C iPhone的OBJ-C ++(.mm)绑定发动机在iPhone和Android中使用Java绑定到相同的发动机,它应该是完全可能的。

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.

所以C ++ / C发动机(几乎相同的codeBase的Andr​​oid和iPhone)+薄绑定层=便携式code。

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

这篇关于跨平台的iPhone / Android的code共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆