简体   繁体   中英

Android & iOS: How to develop for both?

I want to develop an application for both android and iOS devices. Is there a way to develop the application once and deploy on both? Or is it a must to develop for each platform separately?

If you want applications that provide a native experience, then you will have to write separate applications.

I think the best place to start is with a really nice web version optimized for mobile browsers. I think the nicest web apps are better than a lot of the native apps, but they aren't competitive with the better native apps.

There are also a couple of options like Titanium or PhoneGap , which are kind of hybrid web/native systems, they use web technology to build native apps.

Well you have http://monotouch.net and http://monodroid.net . That way you can have common business logic and only re-develop your UI.

It all depends on the type of application you want to develop. If it's a game, I suggest you write most of it as native code, and take advantage of the fact that OpenGL ES 2.0 is supported natively on both platforms. Obviously all of your Java code won't be reusable on iOS, so anything that can be made as a portable native library helps reducing the amount of non-reusable code.

There are a lot of choices. It depends if you want a Native experience or if you want things to be in a webview. With native experience you may have to do some native coding, but it is still way better than developing 2 separate native applications.

Below are some that i have experience with.

Native Experience

Webview

Using Qt, which is a C++ framework for cross-platform developement that has both a LGPL and a commercial license, you can develop for both platforms and simply recompile your app from the same source. As a bonus, you could target Windows, Linux and Mac as well.

Keep in mind, however, that Qt renders its own controls, so widgets will not look native on Android nor on iOS. Also, as with all cross-platform frameworks, it will provide you with the lowest common denominator in terms of features.

From their official blog :

With Qt you can develop truly cross-platform applications that will work on desktop, embedded and mobile platforms. Qt 5.2 introduces full support for Android and iOS platforms and thus enables the creation of cross-platform mobile apps that are packaged and deployed to both Google Play and App Store from one code base. Instead of writing two versions of the same code with two different technologies, you can write it once with Qt!

Apple App Store might not accept apps that use dylibs, however, which might force you to use the commercial license for closed-source apps:

On iOS it is possible to use a dynamically linked version of the Qt libraries, and have them bundled with the application. This allows the app to use the LGPL license for Qt whilst allowing the app itself to be closed source. It remains to be seen whether Apple will accept applications that bundle dylibs into the iOS App Store. If Apple does not accept applications that use bundled dylibs into the App Store, then it will be necessary to link Qt statically to the application. And as the Qt for iOS port uses the LGPL version of Qt, the rules for statically linking with LGPL will kick in - this can be a problem for closed source apps.

Finally, since Qt is a C++ framework, you will need to use C++ to develop your app.

Codename One is another, for Java development on both platforms. No experience with it, though.

If it's a game or primarily graphical app, BatteryTech Engine will do what you want. Yo still need XCode to build for iOS, but otherwise it's a single primary codebase for both platforms.

I started using NativeScript and it looks promising.

NativeScript is how you build cross-platform, native iOS and Android apps without web views. Use Angular, TypeScript or modern JavaScript to get truly native UI and performance while sharing skills and code with the web. Get 100% access to native APIs via JavaScript and reuse of packages from NPM, CocoaPods and Gradle. Open source and backed by Telerik.

I have used lots of cross-platforms in the last few year, and the from my perspective Xamarin is the best because at the end it, you can tell if the app is cross-platform or not. but with Xamarin it compiles to native so no apparent difference between them in terms of UI. You can start here: https://www.xamarin.com

Nowadays you can use Flutter , ReactNative for building apps for different OS from single code base. Both of them have advantages and disadvantages

But in my fumble opinion the best choice is to write a native code on native language using native IDE. It is not a complicated task especially that high-lavel languages use same princesses(Java, Kotlin, Swift). You will be able operate by native components and strategies which are supported, have latest updates and tutorials. In any case if you have high-perfomance task you can use C++ for sharing core code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM