Wei Wen
Wei Wen

Reputation: 413

How to create react native wrappers for native android and iOS SDKs

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.

Upvotes: 0

Views: 3689

Answers (2)

Wei Wen
Wei Wen

Reputation: 413

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".

Upvotes: 1

user9106403
user9106403

Reputation:

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.

Upvotes: 0

Related Questions