<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alex Lockhart on Medium]]></title>
        <description><![CDATA[Stories by Alex Lockhart on Medium]]></description>
        <link>https://medium.com/@alex.lockhart?source=rss-1b693740e168------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZlIW_v3uM9Vup9JMoZzayg.jpeg</url>
            <title>Stories by Alex Lockhart on Medium</title>
            <link>https://medium.com/@alex.lockhart?source=rss-1b693740e168------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:41:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alex.lockhart/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cross Platform Library for Mobile]]></title>
            <link>https://medium.com/well-red/cross-platform-library-for-mobile-f91e541d98a8?source=rss-1b693740e168------2</link>
            <guid isPermaLink="false">https://medium.com/p/f91e541d98a8</guid>
            <category><![CDATA[cross-platform]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Alex Lockhart]]></dc:creator>
            <pubDate>Mon, 25 Jun 2018 16:17:40 GMT</pubDate>
            <atom:updated>2018-09-11T12:48:41.152Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SirkDWxB54lUxwYtHtgWxQ.jpeg" /></figure><p>One of the difficulties in developing mobile apps on multiple platforms is that the same data models and logic have to be written multiple times. A cross-platform library that would work on a variety of platforms, would require only a single code base to be written for the business logic and would serve as a single point of truth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JV-gyH7h2WtxvlqhVMB3Vw.png" /><figcaption>A summary of our options, as they compare across platforms and feature support</figcaption></figure><h3>Options</h3><h4>React Native [3]</h4><p>React Native, like ReactJS, has the support of Facebook. React Native in a nutshell is a tool for bridging JavaScript (JS) and native code. The downside of React Native is that calls through the bridge are asynchronous, and callbacks cannot be passed as arguments. That means that trying to call a function and retrieve a value from the JS code involves a non-trivial amount of boilerplate in native code.</p><p>That in mind, React Native has the widest support of all of the options we are considering. It is built to handle iOS, tvOS, and Android, but the libraries could also be reused in a web application — it’s just JavaScript. Functionality can either be handled using the JS standard library, or third party packages can be imported and used from NPM or Yarn. React Native also gives the opportunity for creating views and UI components that are cross-platform, something the other options don’t offer.</p><h4>Embeddinator-4000 [11]</h4><p>Embeddinator-4000 falls under the Mono umbrella, a group sponsored by Microsoft that develops an open source implementation of Microsoft’s .NET framework for cross-platform use. Embeddinator-4000 (E4K) allows us to wrap compiled C# code into a framework for use in native applications. E4K also has the benefit of being the second fastest option, second only to Go [3].</p><p>The downside to E4K is the health of the tool — the currently available version in the .NET package manager, Nuget, is buggy [1, 2] and currently requires the tool to be built from the master source in order to have it work properly.</p><p>Once it’s working, E4K supports iOS, tvOS, and Android. Because it wraps libraries made with Xamarin tools, this support is fairly mature. Since the implementation is built as a Portable Class Library, we have access to just a subset of the standard .NET library [7] — not every platform supports the entire standard library. Some popular third party projects such as Json.NET are supported, though these third parties must support the limited library PCLs have access to. UI elements could be written in the .NET library and exported out to the native code, but they aren’t properly cross-platform (iOS UI components won’t run on Android), so it would be better to simply write these views in the native code — in the long run, this is a preferable direction to take anyway. The purpose of the cross-platform library should not be to handle UI view implementations, but to handle the logic and services behind that UI.</p><h4>J2ObjC [6]</h4><p>As E4K is backed by Mono and Microsoft, J2ObjC is backed by Google. The benefit to using J2ObjC is that for Android, there is nothing more to be done other than importing the library files. Those files then just have to be converted to Objective-C (which in turn calls emulated Java library functions) for use in our native iOS and tvOS projects.</p><p>The downside, however small, comes from the supported standard library of Java — while it appears that many common libraries are available such as networking, the developers do note that not everything may work out of the box. This isn’t an issue for a library targeting iOS and Android, as although for J2ObjC the javax.* libraries are not available [14], they are also not available for the most part on Android. J2ObjC is also the slowest on average of the options considered. On iOS, this could be due to having to link a JRE emulator to the bundle and dispatch calls to it to emulate the Java code.</p><p>Android support is a given, and J2ObjC allows targeting both iOS and tvOS. The list of standard library functions that are not supported is not advertised terribly well by the developers, leading to uncertainties if a Java class will translate correctly. Unlike React Native and E4K, there is no support for building UI elements — this is a deliberate choice made by the J2ObjC team, who envision the tool being solely for models and business logic.</p><h4>Go Mobile [5]</h4><p>Like J2ObjC, Go is backed by Google. Go has the benefit of being the fastest option that was considered, and has the benefit of requiring the least amount of overhead to implement — the CLI tool builds frameworks that can be immediately imported into Xcode or Android Studio without any overhead.</p><p>However, the gomobile compiler is still in an experimental phase. Because it is experimental and not terribly active, the future of the tool is unclear — it may quickly fall out of step with the Go language and be rendered useless without more consistent contributions.</p><p>Go has good Android support, but the gomobile compiler doesn’t include bitcode in the iOS and tvOS frameworks that it builds. This means no support for tvOS, which requires bitcode. There is also the possibility of Apple requiring bitcode for iOS apps in the future, which would break Go Mobile. A cross-platform library in Go has access to the full Go standard library, as well as the extensive community of packages that can easily be imported.</p><h4>C++</h4><p>Unlike the other options, C++ support doesn’t come from a third party tool. The support for C++ comes directly from the SDKs for iOS and Android, and its level of support is inherent to the platforms, with Objective-C and C++ compiling down to and in Java’s case, being interpreted by, a C engine.</p><p>C++ on iOS is supported through Objective-C++ — Objective-C++ simply takes the extensions that Objective-C adds to C, and adds them to C++. Android Support comes from the Android Native Development Kit (NDK) and Java Native Interface (JNI). Support is focused on C, with C++ supported so long as functions are linked to C.</p><p>Overall, C++ has too many issues to be considered — the wrapper functions for Android would be palatable had the type system not been so far removed from that of C++ and Objective-C, leading to issues when trying to interface with vanilla C++ code. iOS simply requires an Objective-C++ wrapper class to act as the intermediary between the Objective-C and the C++, but on Android the JNI interface is a far step from vanilla C++. Functions that are requested by native code must be exported through JNI, as well as named in a specific means that locks them for use by a single Java class. The JNI types are also not wholly compatible — for instance, there is no easy way of converting from a JNI jstring to a C++ std::string.</p><p>To add to it, C++ has no native networking functionality, and, at least on Android, seems to be painfully slow. When testing performance, the same task on Android took over 3.5x times longer to complete than on iOS — this was not the case with the other options that were tested.</p><h4>NativeScript [12]</h4><p>NativeScript, like React Native, benefits from the backing of a company — though, a company much smaller than Facebook, Progress Software. NativeScript is a framework for building mobile applications using JS, similar to React Native. According to the State of JavaScript 2017, only ~1000 survey respondents had used it, compared to ~5000 having used React Native [13].</p><p>The differentiator for us using NativeScript over React Native would be the ability to have synchronous calls into JS libraries. However, the same issues remain for networking calls, which are required to be asynchronous.</p><p>NativeScript rolls their own implementations of common JS libraries, networking being one of them. This boils down to having to read NativeScript API documentation to learn how they have implemented standard JS libraries, instead of being able to rely on the implementation that would be normally found in Firefox or Chrome.</p><p>The frameworks that NativeScript uses for handling the JavaScript files do not have bitcode, and so tvOS is written off. Possibly due to embedding NativeScript being a currently experimental and unsupported feature, I was not able to get Android to execute JS code. Though my testing was only on iOS, NativeScript is slow. Given that the function bodies being tested were identical to those tested in React Native, the issues must lie in the implementation of the JS engine in NativeScript.</p><h4>Flutter [4]</h4><p>Flutter is very similar to Go in that it is a spin-off from Google that sees contributions from Google team members as well as the community. Flutter is built on the Dart language, also a Google spin-off — so long as Google is committed to Dart and to Flutter, the project shouldn’t falter.</p><p>Flutter is very similar to React Native in that it is a means of creating native apps using an intermediary. However, Flutter offers no such bundle as React Native does; instead, the native code inherits from Flutter classes that handle loading the code in the background. Without a bundle that can be loaded at runtime, Flutter is not something that can be used for developing a cross-platform library. However, Flutter is still in the alpha stages — it may be worth revisiting in a year to see if it has become feasible.</p><h4>Kotlin/Native [9]</h4><p>Kotlin has the backing of JetBrains, the company behind IDEs like IDEA and Android Studio. Kotlin has also been accepted as a language for Android development [10] Kotlin/Native is one of a set of cross-platform targets that Kotlin aims to support, the others being Kotlin/JVM and Kotlin/JS. Kotlin/Native is meant to support a variety of architectures, with iOS being one of them. Support for Objective-C system calls has only just been introduced to Kotlin/Native in November 2017.</p><p>In one example of an app made with Kotlin/Native [8], native code only served as stubs — for most of the options that we are considering, there is either a framework or bundle asset that is imported or loaded at runtime for the native code to interface with. For Kotlin/Native, instead of bundling a resource for the native code to access, it replaces all of the native code with Kotlin — there would be no room to write UI views in native code and have them interface with Kotlin/Native, as the build steps would overwrite all of the native code. Given how new Kotlin/Native is, and the apparent workflow of developing iOS apps using it, it doesn’t seem feasible in the short term.</p><h3>Recommendation</h3><p>Ultimately, the recommendation boils down to what is required. If UI components are required, then React Native and its sizeable overhead become a feasible option — otherwise, the wrapper classes are not worth writing. If it comes down to speed, E4K is a good choice to make, so long as a stable version of the tool is being used. If the language the library is written in is an issue, J2ObjC should be considered — it allows Android developers to build classes as they would normally, and then have those classes ported over to Objective-C.</p><p>Go should be considered in the future if it gains bitcode support — in that case, it should replace E4K. C++ is far too much trouble to be worth it — with options like E4K offering plug-and-play implementations, there is no sense in spending time writing the JNI wrappers and dealing with converting types. Flutter and Kotlin/Native are promising, and would benefit from keeping a close watch.</p><p>If cross-platform libraries in general are considered going forward, then a healthy attitude towards giving back to these open source projects should be considered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zs0v0wPlHSa9usAMXuFV1g.png" /></figure><h3>Conclusion</h3><p>Using either React Native, Embeddinator-4000, or J2ObjC should ensure that time spent developing cross-platform projects is lowered. It should also aid in easing the task of estimating these projects, as it ensures that there will only be a single instance of the logic for the project.</p><p><em>For REDspace’s more in-depth analysis of these options, as well as an investigation into the health of the projects and impact that has moving forward visit </em><a href="https://www.redspace.com/?utm_source=Medium&amp;utm_medium=Boiler%20Plate&amp;utm_campaign=cross_platform"><em>redspace.com</em></a><em>.</em></p><h3>References</h3><p>[1] [Android] Embeddinator build fails while generating Java stubs · Issue #530 · mono/Embeddinator-4000: 2017. <a href="https://github.com/mono/Embeddinator-4000/issues/530"><em>https://github.com/mono/Embeddinator-4000/issues/530</em></a>. Accessed: 2017–12–18.</p><p>[2] [Android] MonoAndroidToolsPath path is not found · Issue #531 · mono/Embeddinator-4000: 2017. <a href="https://github.com/mono/Embeddinator-4000/issues/531"><em>https://github.com/mono/Embeddinator-4000/issues/531</em></a>. Accessed: 2017–12–18.</p><p>[3] facebook/react-native: <a href="https://github.com/facebook/react-native"><em>https://github.com/facebook/react-native</em></a>. Accessed: 2017–12–19.</p><p>[4] flutter/flutter: <a href="https://github.com/flutter/flutter"><em>https://github.com/flutter/flutter</em></a>. Accessed: 2017–12–19.</p><p>[5] golang/mobile: <a href="https://github.com/golang/mobile"><em>https://github.com/golang/mobile</em></a>. Accessed: 2017–12–19.</p><p>[6] google/j2objc: <a href="https://github.com/google/j2objc"><em>https://github.com/google/j2objc</em></a>. Accessed: 2017–12–19.</p><p>[7] Introduction to Portable Class Libraries — Xamarin: 2017. <a href="https://developer.xamarin.com/guides/cross-platform/application_fundamentals/pcl/introduction_to_portable_class_libraries/"><em>https://developer.xamarin.com/guides/cross-platform/application_fundamentals/pcl/introduction_to_portable_class_libraries/</em></a>. Accessed: 2017–12–18.</p><p>[8] JetBrains/kotlinconf-app: <a href="https://github.com/JetBrains/kotlinconf-app"><em>https://github.com/JetBrains/kotlinconf-app</em></a>. Accessed: 2017–12–18.</p><p>[9] JetBrains/kotlin-native: <a href="https://github.com/JetBrains/kotlin-native"><em>https://github.com/JetBrains/kotlin-native</em></a>. Accessed: 2017–12–19.</p><p>[10] Kotlin and Android | Android Developers: <a href="https://developer.android.com/kotlin/index.html"><em>https://developer.android.com/kotlin/index.html</em></a>. Accessed: 2017–12–18.</p><p>[11] mono/Embeddinator-4000: <a href="https://github.com/mono/Embeddinator-4000"><em>https://github.com/mono/Embeddinator-4000</em></a>. Accessed: 2017–12–19.</p><p>[12] NativeScript/NativeScript: <a href="https://github.com/NativeScript/NativeScript"><em>https://github.com/NativeScript/NativeScript</em></a>. Accessed: 2017–12–19.</p><p>[13] State Of JavaScript Survey Results: Mobile &amp; Desktop Frameworks: 2017. <a href="https://stateofjs.com/2017/mobile/results/"><em>https://stateofjs.com/2017/mobile/results/</em></a>. Accessed: 2017–12–18.</p><p>[14] When Compiling with j2objc: javax.* packages are not found: 2017. <a href="https://stackoverflow.com/questions/47609222/when-compiling-with-j2objc-javax-packages-are-not-found"><em>https://stackoverflow.com/questions/47609222/when-compiling-with-j2objc-javax-packages-are-not-found</em></a>. Accessed: 2017–12–18.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f91e541d98a8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/well-red/cross-platform-library-for-mobile-f91e541d98a8">Cross Platform Library for Mobile</a> was originally published in <a href="https://medium.com/well-red">Well Red</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>