Chinaunix首页 | 论坛 | 博客
  • 博客访问: 463772
  • 博文数量: 145
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1060
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-22 11:52
个人简介

专注计算机技术: Linux Android 云计算 虚拟化 网络

文章分类

全部博文(145)

文章存档

2016年(3)

2015年(21)

2014年(75)

2013年(46)

我的朋友

分类: iOS平台

2014-10-11 02:56:55

Cross-platform (iOS/Android) Mobile App development using C++

At , we use tons of C++ & OpenGL for our Mapping applications.

Funny enough, when I talk to tech-people about our startup and tell them that we have a cross-platform framework, the first words that come out of their mouth is “HTML5”. Although we do use HTML5 for some of our components (a topic for another day), they always end up looking surprised when I tell them that 90% of the code is C++ (the other 10% being platform specific GUI + glue code).

Yes. Actually, it gets better.

The truth is that the same core client C++ code runs completely fine on OSX, Android, iOS, Windows, Linux, FreeBSD and possibly other platforms that we have not bothered to attempt.

C++ is an awesome versatile language with tons of libraries that, when carefully chosen, will make your life easier because they work completely fine on different platforms.

  • Need to do threading? Use or .

  • Local storage? How about .

  • UTF16 support? Know about ICU (we use something different, but I had to mention it).

  • Network Access? How about cURL. Yeah, I know, the cURL API might not be the most beautiful thing. But writing a .

  • JSON? , ,

You can have it all (mostly).

By now you may be asking yourself, “I know how to write C++ and use those libraries, but how do I consume them in, say, Android and iOS?”.

For iOS, you need to be aware that there is such thing as Objective C++ and this makes consuming C++ from Objective C trivial. There are several excellent

For Android, you need to be aware that there is such thing as a native sdk (aka android ndk). Again, there are several good tutorials online that explain the process.

In our case, the GUI code is (intentionally) platform-specific because we want to get the native control feel for each phone that we target. We also have a small set of wrappers for phone specific things like access to the phone sensors (a topic for another post).

Is it all as awesome as it sounds?

Sadly - no.

IMHO, there is a huge downside to it all: the build completely sucks.

Think about how many targets you have. Just in iOS, you can have x86, armv6, armv7 depending if you are running this on the emulator, or different iPhones. Every single dependency that you add will need to be compiled for that target. Then think about debug + release. Yuck!

So what to do about this?

At , we use a custom build system for this. Nevertheless, when I was looking into this some months back, I stumbled .

itself is simple and works. Perhaps, if there is enough interest, I’ll write a small “Hello World” app that uses CMOSS to build both iOS and Android apps.

阅读(1671) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~