Objective-C for Android

Cross-platform iOS development


At Apportable, we believe:


Rewriting your app to support other platforms is a waste of a developer's time and creativity.

Developers should be able to use the best tools and languages to develop mobile apps that work on multiple platforms.

About Apportable

  • Founded Winter 2011 with YCombinator
  • First app, Osmos, shipped January, 2012
  • Raised $2.4m led by Google Ventures 
  • Today power dozens of best sellers on Android 


What exactly is the Apportable SDK?


The Apportable SDK compiles your Objective-C (iOS) source code into a native application that runs on Android

 



What Apportable is NOT

  • It is NOT source code translation 
  • It does NOT generate Java
  • It is NOT an iOS emulator on Android (i.e. WINE) 



    How does Apportable work exactly?

    What trickery is this? 


    Lets port something!


    • Visit www.apportable.com and sign up
    • Install the SDK and toolchain
    • Open a terminal and navigate to your source code
    • Plugin an Android device
    • Run apportable load and answer a few questions about your app
    • Thats it. You should see your app running on Android!




      The Apportable SDK includes...

       

      Frameworks
      and libraries

      UIKit
      Boost
      ICU
      libpng, libgif, libtiff, libjpeg
      CoreGraphics
      OpenAL
      CoreAnimation
      libobjc
      C++11 (libc++)

      libc
      libdispatch
      Core Foundation
      Foundation



      The same clang compiler used in Xcode


      Our own fork of clang with added support for Android


      Debugging and tools

      • Latest GDB 
      • Our own Apportable profiler suite
        • memory, network, performance
        • resembles a mini instruments
       

      Support for many binary 3rd party libraries

      • Flurry, AdMob, Chartboost, etc.
       

      • Most source libraries work out of the box (Facebook, DropBox, etc.)


      The Best Features

      • ARC
      • C++11 
      • Assembly
      • Objective-C literals
      • Objective-C Runtime API (swizzling, etc)



      Essentially, you ship a user land implementation of the iOS libraries in your app with Apportable. 

      Only 6mb of dependencies.

      We have done the hard work of supporting the fragmentation in Android





      Customizing For Android

      A little optimization goes a long way towards presenting a native experience on Android.


      Customizing your Android build 

      • Edit the .approj directory generated next to xcode project
      • In the <project>.approj/configuration.json file you can:
        • Add and remove source files
        • Tweak the APKs features and permissions on Android
        • Change defines, icons, and other settings

       

      Support More Screen Resolutions

      • Handling the native resolution is best and will always look the better
      • If you made assumptions about iOS screen sizes, you can emulate them on Android and scale your UI up with UIScreenModes

      #ifdef ANDROID
        [UIScreen mainScreen].currentMode = 
           [UIScreenMode emulatedMode:UIScreenBestEmulatedMode];
      #endif


      Add Hardware Button Support

       - (void)buttonUpWithEvent:(UIEvent *)event
       {
          switch (event.buttonCode)
          {
              case UIEventButtonCodeBack:
                  // handle back button if possible,             // otherwise exit(0)
                  break;
              case UIEventButtonCodeMenu:
                  // show menu if possible.
                  break;
              default:
                  break;
          }
       }
      
       - (BOOL)canBecomeFirstResponder
       {
          return YES;
       }

      Use different device information

      UIDevice+Apportable.h
      @property (nonatomic, readonly) NSString *nativeCPUABI; 
      // e.g. "armeabi-v7a"@property (nonatomic, readonly) NSString *nativeModel;  
      // e.g. @"Xoom"
      
      @property (nonatomic, readonly) NSString *nativeManufacturer;
      // e.g. @"Motorola"
      @property (nonatomic, readonly) NSString *nativeSystemVersion; // e.g. @"4.2" @property (nonatomic, readonly) NSUInteger nativeSDKVersion; // e.g. Froyo is 8 @property (nonatomic, readonly) NSString *macAddress; // requires access_wifi_state @property (nonatomic, readonly) NSString *odin; // open device identifier number @property (nonatomic, readonly) NSString *nativeSecureIdentifier; @property (nonatomic, readonly) NSString *telephonyIdentifier; // read_phone_state
      @property (nonatomic, readonly) NSString *carrierBranding; // e.g. @"Verizon"


      BridgeKit

      • BridgeKit is a fully Objective-C API for bridging to Java and calling Android APIs or custom Java code
      • Used to back much of UIKit and system APIs


      Bridging Application Lifecycle

      • Apportable backs iOS lifecycle events with their Android counterparts
        • application:didFinishLaunchingWithOptions:  --> Activity.onCreate
        • applicationDidBecomeActive: --> Activity.onResume
        • applicationDidEnterBackground: --> Activity.onStop
      • When apps are in the background, Apportable emulates iOS behavior by suspending them


      Push Notifications and Local Notifications

      • Push notifications are handled by Google Cloud Messaging on Google Play Apps
        • Other push notification services such as Parse and Urban Airship are supported as well
      • Local notifications translate to a custom alarm service


      In App Purchasing (StoreKit)

      • Apportable store kit bridges to Google In App Billing (on Google Play) and Amazon Payments (on Amazon App Store)
      • Near full StoreKit compatibility

      Framework Support


      • Foundation - Near full coverage. Major revision in development

      • CoreFoundation - Common classes covered. Full support in development

      • CoreAnimation - Limited. New version in development backed by OpenGL

      • UIKit - Current shipping version is limited to simple UIKit apps. Full UIKit support backed by new CoreAnimation in development

      • CoreData - Working. Limited to automatic migration support only

      • AVFoundation - Audio but no video support

      • MediaPlayer - Video and audio supported (codecs depend on device, ogg is the most universal)

      • OpenGL and OpenAL - Full coverage of latest versions

      iOS 7 Features

      • SpriteKit - In development; currently 20% faster than iOS (even on iOS)
      • GameController API ready

      OpenGL based UIKit preview


      Cocos2D

      • The most popular open source Obj-C game engine, cocos2d-iphone, is maintained by Apportable engineers.
      • SpriteBuilder (formerly CocosBuilder), an animation editor for cocos2d, is developed by Apportable engineers.
      • Chipmunk Obj-C physics engine (included in cocos2d) is developed by Apportable engineers.
      • cocos3d also sponsored by Apportable
      • And more! http://github.com/apportable

      About me

      • My name is Zac Bowling
      • Platform Engineer at Apportable
      • 100+ hackathons in the last 4+ years (may of seen me in Wired Magazine, Business Insider, or Dutch public television)
      • Email: zac@apportable.com

      @zbowling

      Objective-C for Android

      By Zac Bowling