Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking the library with a React-Native module #1

Open
gaithoben opened this issue Oct 30, 2021 · 8 comments
Open

Linking the library with a React-Native module #1

gaithoben opened this issue Oct 30, 2021 · 8 comments

Comments

@gaithoben
Copy link

Thank you so much for the good job of compiling the library making it very easy to use in a project.

I have struggling with an issue the last three days.

I am building react-native module to consume in a react-native project using https://github.com/brodybits/create-react-native-module

Am not sure if am placing the "include" directory in the right place.

am getting the error when i import lbtdjson in a .swift file.

: error: no such module 'libtdjson'

Your help will be highly appreciated.

@up9cloud
Copy link
Owner

Hi, I wonder you didn't create the module_map file for swift. Please check this: https://github.com/up9cloud/ios-libtdjson#use-it-as-module-ios-swift

@gaithoben
Copy link
Author

Thank you so much for your reply.

Actually i did, and it works well when i use it directly in my react-native application.

But when i try to extract it on an npm module that i can easily install, Im stuck. I really dont know what am doing wrong.

/Users/bernardgaitho/tests/cJamboTest2/node_modules/react-native-tdx/ios/TdJsonClient.swift:10:8: error: no such module 'libtdjson' import libtdjson

@up9cloud
Copy link
Owner

Well, I guess it's the same thing. after you installed the pod, you need to create the module file and configure it for swift. I don't think "create-react-native-module" will do it for you.
Did you check the pod folder which create-react-native-module installed for your project?

@up9cloud
Copy link
Owner

I meant the create-react-native-module is actually doing installing pod and wrapping. You have to check the pod folder they installed for you.

@gaithoben
Copy link
Author

In my example project, https://github.com/gaithoben/react-native-tdx.git, i have adjusted the .podpecs file so that the library is installed in the projects 'ios/Pods/libtdjson' folder.

I guess configuring at the module is whats giving me a headache.

@gaithoben
Copy link
Author

Your help will be highly appreciated.

@up9cloud
Copy link
Owner

In my example project, https://github.com/gaithoben/react-native-tdx.git, i have adjusted the .podpecs file so that the library is installed in the projects 'ios/Pods/libtdjson' folder.

I guess configuring at the module is whats giving me a headache.

I think there are 2 ways to solve this:

  1. to figure out why -l"tdjson" -fmodule-map-file="${PODS_ROOT}/Headers/Public/libtdjson/libtdjson.modulemap" didn't work as expectation. (have to check the .xcconfig)
  2. download the libs and build it as a xcframework then manually add it to your lib in xcode (you might want to try https://github.com/leoMehlig/TDJSON/releases/tag/v1.6.1 )

@gaithoben
Copy link
Author

Thank you for your reply. Let me test your suggestion and i will keep trying and researching...

I have never built a native project in native swift or objective c, i guess thats the reason why i find it difficult.
It was not difficult to make it work in android. But to be honest this is not easy for me in iOS, if you can spare sometime and make a working example package for react-native, i will be ready to facilitate that. My email is gaithoben \at \gmail .com.

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants