Apportable (a much better alternative to Phonegap) and AFNetworking 2.0

by Tom van ZummerenOctober 22, 2013

cocoahead_sm2On October 16th I attended CocoaHeads, an iOS developer meetup that is organized every few months by Peter Robinett of Bubble Foundry and other volunteers. Every time it’s hosted at a different location. It was previously hosted at Spil Games, Xebia and NOS. This time it was hosted at eBuddy. The formula is simple: great speakers show up and talk about interesting frameworks, hacks, tricks and so on. During the presentations, attendees can enjoy some free drinks and food.

This was the fourth time I went and it was the best edition yet! That’s why I decided to blog about it this time. I believe this was the best edition because there were talks given by two speakers from San Fransisco: Matt Thompson and Zac Bowling and they talked about some pretty interesting and even mind blowing topics.

About the Speakers

Matt Thompson is a developer and designer working at Heroku in San Francisco, and the creator of AFNetworking, Helios and He is also the author of the NSHipster blog, recognized to be one of the most important blogs about iOS software development. Don’t try to google the name “Matt Thompson” because it is seriously the most commonly used name in the history of names ^^.

Zac Bowling, who calls himself a “hackaton legend”, has worked as a professional software developer since he was 14 years old and is an award winning mobile developer with several apps in various app stores. He is currently an engineer at Apportable. Precisely his talk was about Apportable, along with news about Cocos2D and Sprite Builder.

Matt Thompson – AFNetworking 2.0


Matt Thompson is the creator of the popular AFNetworking framework on iOS. Everybody who has worked on an iOS app that uses HTTP connectivity must have at least heard of this framework, and is probably using it. To explain this to Java developers: AFNetworking is equivalent to HttpClient, which makes it easy to implement HTTP connections.

His talk was about all the wonderful new things in AFNetworking 2.0. A few highlights:

(the death of) AFHTTPClient

This is an important API change. Matt explained that AFHTTPClient became overburdened with responsibilities:

  • Creating requests;
  • Serializing query string parameters;
  • Determining response parsing behavior;
  • Creating and managing operations;
  • Monitoring network reachability.

Now the whole component is modularised, so you can choose the features you want to use in your app.

Security Policy

One of the classes that was pulled out from AFHTTPClient is AFSecurityPolicy. This is a very important security feature in network libraries, enabling developers to verify server identities. Just bundle a certificate in the application, and if the server response certificate is not correct, the request is invalidated. Without this security system, applications are vulnerable to man-in-the-middle-attacks.

Server-Side Data Push

AFNetworking now provides support for server-side data push. It follows the Rocket technique, based on the Server-Side Events and JSON Patch standards.

Zac Bowling & Apportable


And now I would like to talk about a product called Apportable that absolutely blew me away. Zac Bowling is a developer at Apportable and he explained us all about it.

What is Apportable?

Apportable is a technology allowing developers to cross-compile an iOS application into an Android one. In Zac’s own words, “rewriting your app to support other platforms is a waste of a developer’s time and creativity.” He mentioned that while there are solutions to accomplish this, they are usually abstractions which only allow you to use the features that all platforms have in common. Also those apps often have performance issues, and suffer from a lack of visual integration with the underlying OS.

An example of such a solution is PhoneGap. Although I think this is a good product, I think the approach chosen by PhoneGap is the worst way you could think of doing cross-platform app development. What you’re creating with Phonegap are not apps, what you’re creating are websites disguised as apps which feel like you’re using Safari rather than using a native app. With Apportable you can actually build a native app for Android, completely written in Objective-C.


The above image was shown in one of Zac’s slides. Yes, there is no Java! With Apportable developers can write complete Android applications in Objective-C. Apportable includes the option to interact with Android’s UI classes or other Java objects using a framework called BridgeKit.

The Making Of Apportable

What Zac and his team (14 engineers in total) have done is truly remarkable. They rewrote many iOS APIs, like CoreFoundation, Core Animation and SpriteKit, from the ground up for Android. In other words, Apportable is a technology that instead of using Java code, compiles Objective-C into Android applications. In a more anecdotal note, Zac mentioned that his team even found bugs in the iOS APIs, reported them, and fixed them in their own implementation. Even better, their implementation of SpriteKit is 20% faster than Apple’s.

The only real drawback is that the Apportable dependencies are 6 mb in total, which increases the size of the final Android binary.

What Apportable is NOT

Just to be clear, the following list highlights some common misconceptions:

  • It is not a source code translator;
  • It does not generate Java;
  • It is not an iOS emulator on Android.

Apportable instead compiles Objective-C code to a native binary.

Proven technology

Games are a good example of a cross-platform category of applications. They don’t need to look & feel different on different platforms, while business and utility apps usually do. That’s why most of the apps that have used Apportable so far are games. For example, Osmos turned out to be really successful on Android (raised $2.4 million). This doesn’t mean that Apportable isn’t suitable for regular apps using UIKit. It just means that it requires a little more work on your part to make the app look & feel different on the different platforms.

Plans for other platforms

Support for other mobile platforms like Windows Phone, and even desktop systems is in the works. This would be fantastic. Being able to target all mobile platforms with a single code base (and another one for all desktop platforms). Although I think it could get very messy if your code would be full of #ifdef ANDROID and #ifdef WINDOWS_PHONE … but we can’t know for sure whether this is a real problem until we give it a try.

My personal conclusion

Apportable is great, but you should of course always keep in mind that apps shouldn’t look & feel the same on all platforms. So make sure that even if you have a single code base, you create a different UI for each platform. By comparison, take Java desktop apps. They look & feel the same on Windows, Linux and Mac. Do they look native? No. Do they feel native? Not at all. Do they perform well? Nope. We don’t want the same crap on the mobile platforms do we? So forget Phonegap, give Apportable a shot. If you’re not used to Objective C, don’t get scared by the different syntax. In my opinion, iOS truly is the best and most fun mobile platform to use for development. The fact that you can use the same language, frameworks and tools to build your app and then compile it for Android is really awesome!

If you want to see the slides Zac used during the CocoaHeads presentation, you can find them here

Cocos2D & SpriteBuilder

Screen Shot 2013-10-18 at 14.42.50

Zac also talked about Cocos2D and Sprite Builder.

Cocos2D is a popular framework for 2D game programming on iOS. Sprite Builder is a new UI builder for Cocos2D, where developers can simply drag and drop visual elements onto a stage to create a game; it even allows to configure physics and gravity settings within the UI. Zac demonstrated the creation of a simple game within 15 minutes, with only 4 lines of code and the rest built in Sprite Builder. Developers interested in creating iOS games should consider this tool, and when used together with Apportable, games can easily be ported to Android as well. Sprite Builder and Apportable together are a very powerful combination for developing mobile games.

Next CocoaHeads meetup

This was a great edition of the Cocoheads meetup. But I’m not saying others aren’t good as well. So far I’ve learned a lot in each one of them and they continue to have great speakers. They said the next CocoaHeads meetup is going to be in November. I will update you with a blog post when an exact date is announced!