Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Native Cross-Platform

Native Cross-Platform

A better way to build native apps with J2Objc, RoboVM, Xamarin or Djinni?

Avatar for Wolfgang Frank

Wolfgang Frank

March 15, 2016

Other Decks in Programming

Transcript

  1. It is hard! → Develop several native apps ("reuse concepts",

    mobile GW) → HTML5/JS based hybrid apps (e.g. Cordova, Appcelerator)
  2. Other choices → MDSD/MDA model driven approach (e.g. iphonical, applause)

    → JavaScript to native bridge (e.g. Transit) → Commonly used C/C++ libraries (with NDK)
  3. Look at J2Objc → Transpiler: Java source code to Objc

    source code → Open source project from Google → Write non-UI (i.e. data access, application logic) in Java
  4. J2ObjC supports "most" Java language and runtime features → exceptions

    → inner & anonymous classes → generic types → threads → reflection
  5. Compile translated file $ j2objcc -c HelloWorld.m Build an executable

    $ j2objcc -o hello HelloWorld.o $ ./hello HelloWorld hello, world
  6. ! Pros → fast to get started (low learning curve)

    → "readable" runtime code → relatively easy to integrate and debug
  7. ! Cons → need all source code → okay, but

    not great to read code → Objective-C in a Swift world
  8. Our mission is to bring Java to iOS and to

    do it properly. We empower the Java developer. — RoboVM
  9. Look at RoboVM → Cross-compiler: Java bytecode to native ARM

    / x86 → Now closed source aquired by Xamarin/Microsoft → Build complete iOS/Android Apps using native UI’s & full hardware access → Build dynamic frameworks for iOS (NEW)
  10. RoboVM features → Currently based on Android Java Runtime →

    Eclipse integration (Plugin) → RoboVM Studio (IntelliJ based IDE) → Create App Store ready apps → Dynamic frameworks
  11. ! Pros → "easier" for Java developers to get started

    with iOS → Dynamic Frameworks => best of both worlds → Nice IDE support with gradle and RoboVM studio → Great if Android & iOS are only platforms → Based on Bytecode!!! => Kotlin :)
  12. ! Cons → slower build process (turnaround) → Debugging for

    Dynamic Frameworks missing → No Windows support → Future after Microsoft aquisition unclear → Expensive
  13. Look at Xamarin → Cross-compiler: C# to native ARM /

    x86 → Aquired by Microsoft → Build complete iOS/Android/Windows Apps using native UI’s & full hardware access
  14. Xamarin features → Currently based on .NET/Mono → Xamarin Studio

    → Visual Studio (plus Build-Host for iOS) → Create App Store ready apps → "Ahead of Time" compile on iOS → Mono Runtime on Android
  15. ! Pros → "easier" for C# developers to get started

    → Very mature → iOS + Android + Windows → powerful/modern language C# → Good documentation
  16. ! Cons → slower build process (turnaround) → Xamarin Studio

    IDE / Visual Studio → Learning curve for non-C# developers → Expensive
  17. Look at Djinni → Dropbox framework (Mailbox, Dropbox, ...) →

    Create native bindings to C++ (Shared code) → Objective-C++ / Android NDK → Textual DSL -> Generator
  18. Features → Generates interface code -> bidirectional calls between C++

    and Java (with JNI) or Objective-C (with Objective-C++)
  19. Basic data structures my_record = record { id: i32; info:

    string; store: set<string>; hash: map<string, i32>; values: list<another_record>; # Comments can also be put here # Constants can be included const string_const: string = "Constants can be put here"; const min_value: another_record = { key1 = 0, key2 = "" }; } another_record = record { key1: i32; key2: string; } deriving (eq, ord)
  20. Interfaces / Services # This interface will be implemented in

    C++ and can be called from any language. my_cpp_interface = interface +c { method_returning_nothing(value: i32); method_returning_some_type(key: string): another_record; static get_version(): i32; # Interfaces can also have constants const version: i32 = 1; } # This interface will be implemented in Java and ObjC and can be called from C++. my_client_interface = interface +j +o { log_string(str: string): bool; }
  21. How to run src/run \ --java-out JAVA_OUTPUT_FOLDER \ --java-package com.example.jnigenpackage

    \ --java-cpp-exception DbxException \ # Choose between a customized C++ exception in Java and # java.lang.RuntimeException (the default). --ident-java-field mFooBar \ # Optional, this adds an "m" in front of Java field names \ --cpp-out CPP_OUTPUT_FOLDER \ \ --jni-out JNI_OUTPUT_FOLDER \ --ident-jni-class NativeFooBar \ # This adds a "Native" prefix to JNI class \ --objc-out OBJC_OUTPUT_FOLDER \ --objc-type-prefix DB \ # Apple suggests Objective-C classes have a prefix for each defined type. \ --objcpp-out OBJC_OUTPUT_FOLDER \ \ --idl MY_PROJECT.djinni
  22. arconsis - services → iOS & Android trainings (arconsis academy)

    → Mobile development (native + cross-platform + mobile web) → Mobile Gateway / MBaaS (Red Hat Mobile Application Platform) → Mobile strategy & mobile UX → Agile coaching (Scrum, Lean, TDD, ...)