react native linking a library to inside the another library - react-native

Is it possible to link a library which has native dependencies inside another library? Trying to find the solution to link manually, but failing to do it so. I found a [question]: Using React-Native library inside another React-Native library summary, saying It is not possible to add/link a library to another library.
Is there any manual way to do this or not possible?
[Edit]
Trying to add the react-native-spring-scrollview: ^2.0.20 library to my library react-native-demolibrary, which is a library created using react-native-create-library command, since it is a library there were no settings.gradle file. So created and tried to link manually library to react-native-somelibrary.
settings.gradle
include ':react-native-spring-scrollview'
project(':react-native-spring-scrollview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-spring-scrollview/android')
build.gradle
implementation project(':react-native-spring-scrollview')
below error has shown up,
GRADLE CONSOLE ERROR
org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Build file 'E:\Workspace\DemoApp\node_modules\react-native-demolibrary\android\build.gradle' line: 37
A problem occurred evaluating project ':react-native-library'.
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:139)
at org.gradle.initialization.DefaultGradleLauncher.getConfiguredBuild(DefaultGradleLauncher.java:104)
at .....more
ERROR:
Project with path ':react-native-spring-scrollview' could not be found in project ':react-native-demolibrary'.
Open File
Thank you in advance.

Related

Could not find a declaration file for module '#hmscore/react-native-hms-push'

I'm having problems with linking push kit library.
I'm programming in react-native with visual studio code, library '#hmscore/react-native-hms-push' not seem to be imported correctly, the error is 'Could not find a declaration file for module '#hmscore/react-native-hms-push'.
I'm using 5.3.0-301 version.
Checking maps-kit and push-kit seems different si index.ts, is missing in the src directory of push-kit
i have used this guide:
https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/integraternmodule-0000001050157791
have i missed anything?
Thanks
The solution is:
yarn add #types/hmscore__react-native-hms-push
or equivalent in npm.

Problems creating a NativeScript plugin that uses Objective-C code

I have followed the NativeScript documentation on adding Objective-C code to a NS project although I am struggling to call the Objective-C code in my iOS project. I am only trying to implement appPlugin.h and appPlugin.m files into my project.
My folder structure for the Objective-C files are as follows:
Project/app/App_Resources/iOS/src/...
I have also tried creating a NativeScript plugin that gets added to the dependencies in the projects package.json.
Are there any additional files that need to be added to make the Objective-C code compatible with the NS project. The documentation simply says run "If you run 'tns prepare ios' you will see that the files are now part of the project."
Link to the documentation I have been following:
https://www.nativescript.org/blog/adding-objective-c-code-to-a-nativescript-app
https://docs.nativescript.org/plugins/building-plugins
SOLVED: Files are added to the TNSNativeSource folder (Check in Xcode) and are available to use like any JS object.

Calling *.aar files (android library) in nativescript vue

I already create an .aar (android library) files in android studio and want to call/use it in nativescript-vue project.
I have placed the aar file in "app/App_Resources/Android/libs" folder.
Based on my reading, in typescript the way to call the method in aar files is by calling com.package.MyClass.
My question is , how to call it in .vue files. I have tried to call the method using the same approach but its produce an error :
Module not found: Error: Can't resolve com.package.MyClass
Can someone please help me on this.
Your help is very much appreciated.
You may simply place your AAR file in your App_Resources/Android/libs directory, CLI will pick it up at build time and the native APIs should be available at runtime within your project.
Try a clean build if you see errors, make sure the AAR is picked up. You might be able to verify it from the CLI logs. If you still see issues, make sure the class you are trying to access is public.
I'm not sure it's possible to use the android lib directly in the main project or not. In my way, I create a NS plugin that includes the .aar library, then add this plugin to the main project & use the methods defined in the .aar library without problem.
If you place the .aar library in the main project, you should check if that .aar library is installed by running tns build command & look at console log. If it's installed together with the project, that means you can use the lib method in .vue or any .js files.

react native - TypeError: undefined is not a function

I'm exporting an external module of this library: https://github.com/GoIntegro/react-native-account-manager
Since the library is outdated and doesn't work beyond for > 0.47, I had to include this library as an external module.
Everything was working fine, but now suddenly upon calling react-native upgrade, I'm getting this error:
My settings.gradle contains this:
include ':react-native-account-manager'
project(':react-native-account-manager').projectDir = new File(rootProject.projectDir, '../external_modules/react-native-account-manager/android')
And this is in my app level build.gradle file:
dependencies {
...
compile project(':react-native-account-manager')
...
}
Anyone has any idea how am I supposed to fix this? Is there something wrong with the way I'm importing this library or is it something within the library that is outdated that I need to fix?

Unable to locate libMailCore2-ios.a framework file when building MailCore2

I forked the Mailcore2 repo here: https://github.com/MailCore/mailcore2/
and tried to build the libMailcore2-ios.a framework myself.
Clone the repo
Open up the mailcore2.xcodeproj file in build-mac
Select the mailcore ios target and try building with cmd+b
The build succeeds
However, I'm unable to find where this project file exports the libMailcore2-ios.a file. I see the linked products in the project, but they are all red.
Any help?