How to use Swift library in Android native project - android

We have iOS and Android native applications. iOS team implemented the Onvif library in Swift (which also contains Objective-C libraries). We would like to integrate it into the native Android application.
We discovered possible solutions:
Write the same code in Kotlin by ourselves
KMM - if it's possible to share the Swift library
Translate Swift into Kotlin using https://vinivendra.github.io/Gryphon/
Gradle plugin for Swift https://github.com/readdle/swift-android-gradle
We prefer to use the original Swift library as all bugs would be fixed there.
What option do you suggest?
Thank you

Related

Flutter android library and iOS framework

My question is, how do I use .aar files for android and iOS frameworks in flutter?
I am coding a program and I am using flutter. I found .aar files for program and iOS frameworks. How do I integrate both and use them?
I think what you need to use method channel so you can call native code and can connect from Flutter to Android and iOS. https://flutter.dev/docs/development/platform-integration/platform-channels

Can Android library (jar/aar) be used for iOS in Xamarin

I know that I can add Android library (jar/aar) to Xamarin project. If I compile this project for iOS, will it work ? I read that it is not possible because of iOS do not have jvm. Is this situation same for Xamarin ?
Is this situation same for Xamarin?
Yes, you can't add jar to Xamarin.Ios.
Xamarin.Android or Xamarin.Ios is just a wrapper for Native Android or Ios.
You can use c# to code Xamarin.Android project, and run the Xamarin.Android project on a Android device,these all based on Android Callable Wrappers and Managed Callable Wrappers.

How to compile the Xamarin android app with C# classlibrary + C++ Native library?

I have a Chip card reader application which is written by C# and C++ lib as a low-level layer.
Now I want to have the same application in IOS and Android.
So for to achieve this, I have setup the XamarinSDK in VS2017.
I have created the sample android app and imported my existing card reader c# class library and I have calling C++ methods using DllImport inside the C# library and finally compiled both successfully without error.
But when I run the APK on the device it showing exception when calling C++ lib from C# lib.
The code flow is like below image.
So can anyone help me about how to achieve this same?
Highly appreciated your help on this.
Your libs must be compatible with the Android platform. If they're written to Windows or other platform you have to recompile and maybe adapt them. The C# lib tend to be an PCL or .Net Standard lib and the C++ lib have to target the android platform.
I don't have experience with C++ Android development but all C++ applications and libraries have to be compatible with the platform they run.

Is that possible writing a Swift lib for Android NOW?

We're considering to write a lib for both iOS and Android using Swift instead of C/C++.
I found some talks about Swift on Android:
How we put an app in the Android Play Store using Swift
#Pragma Conference 2016 - Axel Schlueter - Swift on Android
Swift on Android: The Future of Cross-Platform Programming or White Whale?
In MillerTechnologies, we are working on that currently. Look those repos out.
https://github.com/MillerTechnologyPeru/swift-android
https://github.com/PureSwift/Android
We base our project on this repo
https://github.com/SwiftJava/swift-android-kotlin
but firstly you need to configure the toolchain
https://github.com/SwiftJava/android_toolchain

unity3d native plugin with objective-c, build for android

Is it possible to build for android with objective-c native plugin in Unity3D? It builds when i press "bıild and run" without error but can't test with emulator since i use native plugin. I don't have an android device either.
Any help would be appreciated.
You'll be able to build for Android, but you won't be able to use an iOS plugin in Android.
In my projects I have multiple plugins for various platforms. By isolating platform dependent code with #if UNITY_platform, where platform ranges from IPHONE to ANDROID, you can effectively have a single code base with multiple platform plugins, that implement functionality in that single code base, by using dependency injection.

Categories

Resources