What i want to achieve is something like creating my own SDK like what react-native-fbsdk or rn-onesignal-sdk provides , so that those functionalities can be implemented in the react native project.
Basic questions :
Where to start from? Like what are the pre-requisites?
Native coding is required i believe for this functionality?
Any explanation or any such experience in such would be of great help .
Where to start from? Like what are the pre-requisites?
You can use a template like this one. It includes an example project which is basically an app that you can use to test integration of your native module and to quickly iterate on it.
Native coding is required i believe for this functionality?
Only if you need to use platform-specific functionality, or provide bindings to some pre-existing native library. Both examples you mentioned do exactly that – because they have native SDKs that can be used in non-RN apps, and they provide React Native bindings for them.
If your library is just business logic + some networking, and you don't intend it to be used in non-RN apps, you can do it all in JS. No need for native code. If you choose to go with the template that I have linked above, there are instructions how to use it to create a pure JS React Native library.
I'll be happy to update my answer if you can share some concrete requirements of what you want your SDK to do.
Related
I'm trying to understand what structure should have a multiplatform library. Checking on the Internet I've seen a huge number of examples explaining how to make a log or a "hello world" but there's a lack of complex examples, even in the official documentation (important to note that I'm only interested in mobile platform, iOS and Android).
So I want to create an example that simply opens the camera (as a lib, not as a multiplatform app) just to have an idea of how to work with a real feature which, also, is native. Right now I have created a project following the official example, so it has a common module (using expect) and one for Android and one for iOS (using actual), and now these are my doubts:
I've seen that the iOS module is also in Kotlin, Kotlin/Native as I understand. Should my project have also an wrapper in Swift, or will the library have no Swift code? And if it should, where should it be in the project structure?
Also in the Android module I've noticed I cannot import the class "Activity" nor the "Intent", which I will need to open the camera, why? is this code restricted to Java without the Android libs? Should it also have a wrapper to Android? If so, how can I configure this wrappers?
I know I can use the "expect" key when creating classes but, as I understand, the common and the native modules will always be separated classes. I mean, if I create a class in the common module, can I define methods of this class using "expect" and define them later in the native?
Can my lib have a Manifest?
Finally, does anyone knows a real example that really explain a more complex situation?
Thanks
Okay, let's go through your questions one-by-one.
I would recommend you to have a look at this example
The
iOS module produces an Objective-C framework as a result. It can be utilized by the Xcode project the same way as any other framework with non-Kotlin origins.
It looks like the unavailability to use
Android SDK is the result of using jvm("android") target instead
of android() one. To use the android target, one has to apply the android Gradle plugin in addition to kotlin-multiplatform one.
I
think you want to do something like that: just ordinary class
declaration in the common and extension function for it with an
expect modifier. And then actualize it in the platform-specific
code.
I think so.
I'd also recommend you to have a look at
this and this, maybe these examples will be complex enough for you.😁
Has anyone had any success using react native to create both iOS and Android apps that can be used as libraries/sub-projects in other iOS and Android native projects that were created without react native? My goal is to create new functionality for an existing app that has both a iOS and Android codebase that was developed without react native.
As a simple example, lets image that I need to create a series of screens and logic to allow a user to 'create a new account'. Ideally I would like to create the new functionality (controller, views, api-client, etc.) using react native and then export it as a self contained iOS and Android app. In addition to being able to run these apps on their own, I would also like to be able to include them in other native iOS/Android projects as sub-projects. The native iOS project would then create a new storyboard/ViewController/segue(s) and link the main-view of the react native iOS App to it.
I know on iOS/xcode I can add a sub-project by drag-and-dropping an .xcodepro into another one. If I did this with a .xcodepro that was created with react native, how would I go about linking the top level view to the existing non-react native iOS project? Is there a similar process on the Android side to achieve the same functionality?
I would like to explore React Native as well. We have similar needs as you - to develop a common library/framework for iOS and Android. Our solution was to code the library in C++ and use it in XCode on iOS and through a JNI (Java Native Interface) converter on Android as well. The JNI is a pain as not everything translates 1 to 1. I researched using Ruby/RubyMotion but that also has a JNI conversion step. There are other languages that do not require a JNI conversion - but from my last read these are also eperimental. Trying all of these will require effort and results are not guaranteed. Assuming aside from the shared library you still want Native for the rest of the App (UI etc), this will require developers with a combination of Swift, React, and Java (which could get expensive) The approach that makes most sense would be to use Swift for the iOS framework and Kotlin for the Android library and use the same style (functional/react-swift/react-java style code) That way, while the libraries are still different, they are coded in the same style so development/maintenance effort on one can be quickly copied/applied to the other.
I am a ios developer , We have a requirement where we have to develop an app (with Maps,GPS tracking,Charts) in both ios and android, We are planning to use Xamarin cross platform to develop so that we can write common business logic for both the projects,
As per my research its not recommended to use xamarin.forms for the apps which needs more platforms specific functionalities like Maps,GPS tracking,Charts
by my research I found Xamrin.ios and xamarin.android are best approach to implement more platform specific functionalities
My question is , Xamarin.ios and xamarin.android are they 2 seperate projects? could I able to share business logic between those? As per my understanding in xamarin.ios and xamrin.android we will be calling our native ios/android APIs and frameworks hence we cant share the code , am I right?
Can we share code in xamarin (Xamarin.ios/xamarin.android) if we dont use Xamarin.forms?
Wat are the benefits we will get if we use xamarin.ios/xamrin.android instead of Native development with obj c / Java ?
You can have a Xamarin.android and Xamarin.iOS project in a single solution and have code sharing with a common business logic using MVVM design pattern , PCL (Portable Class Libraries) and linked source files. For the case of platform specific code in a shared code , inversion of control can be used
You try to squeeze as much as common code behind as possible , so you will only have to implement the GUI twice (Android and iOS)
I need to create an API library for Android and iOS. I have experience working with Android projects, but zero experties in iOS. I was wondering if I could create a Project library in Xamarin that compiles as a JAR for Android and as an... I-don't-know-which-type for iOS.
No, that isn't possible. Depending on what you are trying to accomplish there may be alternatives. If you are trying to make a library that can be used by others you could make it a Xamarin component - there is a component store you could put it on if you want it to be generally available, otherwise you can use any normal means of source or object distribution.
If you need to interact with a native app/library then you could make the C# code the "owner" of it and have it call into the native code. This works for both IOs and Android (and is used to work with e.g the play services from google).
No, it is unfortunately not possible to do that.
It seems to me that what you need is a Portable Class Library also known as PCL. It allows you to create a project which can be referenced by all Xamarin supported platforms (such as iOs and Android). There are obviously limitations to the approach like not being able to reference platform specific libraries but in your case (of writing an API) it should suffice.
You can read more in this link
Good Luck!
Can can tell me how to use the ZXing library in an android app in TITANIUM.I have downloaded the ZXing library from the following path : http://code.google.com/p/zxing/downloads/detail?name=ZXing-2.0.zip
Creating a custom module is the only way to do this. Therefore you have to have knowledge of the native platform.
Modules are not too difficult if you have native platform experience (or just know Java for Android). I would check the moddevguide example module which is chock full of examples of passing data back and forth, which is available in the public Titanium repository on github. Also, the paint module is a great example of subclassing to roll your own titanium component.
So first go here and follow these step-by-step instructions on how to start your own module. Documentation Link
Then check out this code for great examples of passing data throughout your app. Titanium Github
All that aside, if you dont have native platform experience, why not just use either the Titanium Plus modules barcode scanner? Or this open source alternative?
No need to reinvent the wheel at this point.