编译一个 iPhone XCode 项目以在 Android 上工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6117202/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:06:21  来源:igfitidea点击:

Compiling an iPhone XCode project to work on Android

iphoneandroidxcodecompilation

提问by user673829

I have an iPhone app which is written in XCode and is currently selling on the iTunes app store. I want to be able to release it for the Android market. Is there any way to compile my app from XCode to work on the Android operating system. I don't really want to learn a new language and completely rewrite my app, so was wondering if there is an easier way.

我有一个用 XCode 编写的 iPhone 应用程序,目前正在 iTunes 应用程序商店销售。我希望能够为 Android 市场发布它。有什么方法可以从 XCode 编译我的应用程序以在 Android 操作系统上运行。我真的不想学习一门新语言并完全重写我的应用程序,所以想知道是否有更简单的方法。

回答by Tommie

There isn't any way to compile Android apps from Xcode, and i strongly doubt that Apple would introduce such a feature - if it's even technically possible to do. Sorry.

没有任何方法可以从 Xcode 编译 Android 应用程序,而且我强烈怀疑 Apple 是否会引入这样的功能——如果它在技术上是可行的的话。对不起。

But if you have Objective C down, you shouldn't have to much problems understanding Java (which is used for creating Android apps).

但是,如果您没有使用 Objective C,那么理解 Java(用于创建 Android 应用程序)应该不会有太多问题。

Check the link below for a pretty comprehensive guide to start learning java and code for the Android platform:

查看下面的链接,获取一份非常全面的指南,开始学习 Android 平台的 Java 和代码:

http://mobile.tutsplus.com/tutorials/android/java-tutorial/

http://mobile.tutsplus.com/tutorials/android/java-tutorial/

Good luck!

祝你好运!

回答by inazaruk

No, in general you can't do this. Even if assuming Objective-C can be compiled/converted into Java (which is most likely will not be true for times to come), you'll need to rewrite UI part; then most of OS APIs are different too. There are several features that iOS has that Android lacks or does not have open API for it, or has limited API, or has conceptually different or just different API.

不,一般情况下你不能这样做。即使假设 Objective-C 可以编译/转换为 Java(这在未来很可能不会成立),您也需要重写 UI 部分;那么大多数操作系统 API 也不同。iOS 有几个特性,而 Android 缺少或没有开放的 API,或者 API 有限,或者在概念上不同或只是不同的 API。

Its just easier to move some of your iOS code into C/C++ shared library and then make sure that it compiles and works on both platforms. And then make platform dependent pieces separately for each platform (UI, hardware related stuff, etc.). This way you'll have at least part of your code shared.

将你的一些 iOS 代码移到 C/C++ 共享库中,然后确保它在两个平台上编译和工作更容易。然后为每个平台分别制作平台相关的部分(UI、硬件相关的东西等)。通过这种方式,您至少可以共享部分代码。