add third party library to kotlin multiplatform mobile shared module - kotlin

Am writing a KMM mobile app that will be calling an AppSync API, my intention was to implement all the API calls in the shared module so that I don't have to write that code twice (i.e for iOS and Android separately)
Secondly, I want to use the Amplify libraries in the shared module to implement the API calls, am hoping this would allow me to take advantage of lots of features such as offline storage.
What I am noticing however is that even though I have successfully added the amplify libraries in the commonMain sourceSet, the libraries are not visible on the classpath so i can not import any class from the libraries
Here is my commonMain sourceSet dependencies in the build.gradle
val commonMain by getting {
dependencies {
implementation("com.amplifyframework:core:1.35.2")
implementation("com.amplifyframework:aws-api:1.35.2")
}
}
This builds successfully and installs the dependencies but i can't import anything
My question here is,
Does this mean that I can not add any third party that is not a kotlin multiplatform library at all?
I feel like the only option this leaves me is to implement the API calls twice in a platform-specific way which kind of defeats the purpose of using KMM completely, is there an alternative solution that could allow me to use these libraries and write the API calls as shared code that is imported to both iOS and Android apps?
Thank you

I have decided to use https://www.apollographql.com/docs/kotlin/v2/essentials/get-started-multiplatform.
This seems to work well with the KMM, I can build the API calls once and re-use for both platforms.

Related

Add external C++ libraries to react native Turbo app

I am trying out the new react-native Turbo feature.
The calls to the cpp code works as the documentation mentions.
Is there a way to add external C++ libraries like cryptopp.
I have my github repo here RNTurbo.
Try to build your library with https://github.com/callstack/react-native-builder-bob - with interactive CLI you can generate a proper project structure with c++ libraries support for both platforms ios and android

Allowing for Extensible App Architecture in VueJs

I am creating a VueJS app currently that will be open sourced. This app will have a similar internal version as well that includes some differences such as additional features / different auth mechanism etc. I want an architecture where the open source version of the app will be the source of truth. The internal version of the app will extend off the open source app and modify as needed. I am wondering how to achieve this with VueJS with as little code duplication as possible. Ideally, I want to be able to push changes to the open source repo and get updates to the internal version of the app as well.
Note: I have seen examples on the web of this sort of being done with Angular.
The app is split into modules and each module is shipped as an npm module. Then the internal version of the app downloads these modules as npm dependencies and then uses Angular's module system (NgModule) to do code extension.

Using React-Native library inside another React-Native library

I created a React-Native application
Then I created a React-Native Library using this seed github.com/frostney/react-native-create-library
Now, I need to use this package https://github.com/toystars/react-native-geo-fence
Inside of the Library.
Problem is: The library is not a react-native application, and the geo-fence lib needs linking.
I cant change the React-Native App and can not use the geo-fence directly inside of it, of course.
The logic will need to stay inside the Library i created.
When i linked the Library i created (with the geo fence package on it already), with the App i created, the geo-fence gradle settings and android configurations didn't happen at the APP.
this concerns Android only
It is not possible to link a react-native library to another react-native library.
So the correct procedure is to add any third party react-native library, that requires link, that you want to use inside your own react-native library, as peerDependency on package.json.
This way the third party lib will be installed directly at the app, and will be linked, necessarily to the app, but the logic using the third party lib will be inside your own.
So you can create a lib, add react-native-geo-fence as peerDependency of your lib, then code as you wish.
After this, the app using your lib, will have to install it and link manually the react-native-geo-fence, then that's it.

Where I can get detail information to build Restful API?

I developed Flutter mobile app. I need to develop a restful api for my flutter mobile app. I am using macOS and IntelliJ.
I install dart plugin. I try to create a first angular dart project and I found that there is a lib directory which has an error.
lib/generated/i18n.dart and import 'package:flutter/foundation.dart'; also
import 'package:flutter/material.dart'; couldn't found.
What is the steps to create a Angular Dart WebApp project using IntelliJ? I try to install web storm but couldn't find any community edition.
Any help please?
To create an API you need to use a back-end framework, and you would probably want to choose one depending on the languages you know.
If you want to use Dart for the API too, you can't use Angular Dart since that's a front-end framework and you can't use that to build a web API.
Simply Googling, you will find Aqueduct.
About that error: are you trying to import Flutter libraries in a Dart project?

Can you add libraries with native dependencies to an Expo react native project?

Can you use libraries like https://github.com/tolu360/react-native-google-places in an Expo project? I assume any npm library is ok to add, but what about libraries like this google places picker that requires post install steps to link the native projects. Are they supported with Expo?
Regular Expo projects are written only in JavaScript and don't support npm packages that contain Objective-C or Java. However, Expo provides an advanced SDK called ExpoKit for when you absolutely need to use custom native code. From the Expo docs:
Normally, Expo apps are written in pure JS and never “drop down”
to the native iOS or Android layer. This is core to the Expo
philosophy and it’s part of what makes Expo fast and powerful to
use.
However, there are some cases where advanced developers need native
capabilities outside of what Expo offers out-of-the-box. The most
common situation is when a project requires a specific Native Module
which is not supported by React Native Core or the Expo SDK.
You could "detach" your Expo project to create Xcode and Android Studio projects that contain ExpoKit. Then you would add custom Objective-C or Java the same way as with any other Xcode or Android Studio project.
However, the Expo docs also warn about some of the downsides of writing custom native code; many features often can be implemented well in JS, allowing you to retain all of the benefits of a standard Expo project.
Warning: We discourage most of our developers from taking this route,
as we believe almost everything you need to do is better accomplished
in a cross-platform way with JS.
Writing in JS enables you to best take advantage of over-the-air code
deployment and benefit from ongoing updates and support from Expo.
You should only do this if you have a particular demand from native
code which Expo won’t do a good job supporting, such as (for
example) specialized CPU-intensive video processing that must happen
locally on the device.