swiftmobilexamarincode-sharing

How to make shared logic usable for cross-platform native apps?


So I am currently using Xamarin for multi-platform mobile applications. I really like the way this works, and I want to improve my flow. My developers have said that they would be much faster when programming natively (i.e. Swift for iOS in XCode).

I have looked for a solution, where I can create a shared project and use it in native apps, but I have only found ways that involve programming in one language for all platforms.

Is there a way to create a shared project, which can be imported into a native application (or better, can be run together, like a shared project in Xamarin)?

The language for the shared code is not important, as long as it isn't slow.


Solution

  • My developers have said that they would be much faster when programming natively (i.e. Swift for iOS in XCode)

    Swift can be used natively for iOS apps. RemObjects' Silver is supposed to make Swift ready for Android and .NET. I've never tested it. Try it out, it's free.

    RoboVM can be used to write iOS apps in Java. I didn't try it out either.

    Language mixing with Xamarin

    In case you want to mix Swift code with C# code using Xamarin then you can bind Objective-C compatible Swift code and use it in iOS projects only. You are not able to execute Swift code on Android or Windows Phone! It's not possible to write platform independent business logic in Swift and and use it in a shared library or PCL with Xamarin.

    You face the same restrictions for Java code on Android: You can bind JARs and use them in a Xamarin.Android project but you cannot use them on iOS or Windows Phone.

    You are also unable to execute C# code in a Swift based app on iOS or in a Java based app on Android.