0

I am creating a React Native module as a wrapper for existing Android and iOS libraries. The Android library is a jar file and the iOS library is xcframework file. I put the xcframework file inside the ios folder, and the jar file inside android/libs folder ( I created the libs folder). I first tried the iOS library by adding s.preserve_path, s.xcconfig and s.vendored_framework inside the project level podspec file. I am not sure if I need to do anything for the pod spec file, like running it. So I just went along with the next step by trying to import the library's .h in .m file. I tried both using angle brackets <> and using quotes "". But none worked, because firing "react-native run-is" gave me this error: fatal error: file not found. Any help on how to include the libraries in react native is greatly appreciated.

2 Answers 2

1

I was able to fix the error by doing the following two steps:

  1. Change "s.vendored_framework" to "s.vendored_frameworks" in the project level .podspec file. My original one is singular (framework), not plural (frameworks).

  2. cd iOS && pod install && cd ..

Step 2 can be found in create-react-native-module's GitHub link: https://github.com/brodybits/create-react-native-module

I missed the second step when posting my question. I thought then that if I ran "react-native run-ios", it would run "pod install".

Sign up to request clarification or add additional context in comments.

1 Comment

However, the Android version still won't build. The issue is that the android/build.gradle still uses maven plugin, while for Gradle 7, maven is replaced with maven-publish. But just by changing this and a few other things still won't fix the build issue. It comes down to this line: classpath += files(project.getConfigurations().getByName('compile').asList(). "compile" cannot be found. Changing it to "implementation" gave the error: configuration 'implementation' is not allowed as it is defined as 'canBeResolved=false'. Someone has reported the issue in the GitHub page, but it is still open.
0

For creating react native wrapper or node module you need use below library.

https://www.npmjs.com/package/react-native-create-library

https://github.com/brodybits/create-react-native-module

Using this library you can create empty react native module project after that you can bind your native code ARR or framework files into that project.

1 Comment

Thank you for the links. But I already created my empty react native module using create-react-native-mudule when I posted my question. The problem I have is that after I put my .xcframework and .jar library, and for iOS specifically, modified the project podspec file as I did in my question and tried to import my library in the .m file, the project failed to run when I cd to example and typed in "react-native run-ios". For Android, it didn't run even just after I created the empty project. I think there is some setup to be done on Android.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.