Can a native module (React Native) include a Cocoapod dependency?


(Nick ) #1

Hi!

I have created a couple of native modules for React Native to interface with iOS and Android but I’ve never had to concern myself with Cocoapod dependencies until now. I’m working with a vendor that provides an iOS and Android SDK. I would like to wrap this SDK as a React Native plugin that can be shared. The android piece was fairly straight forward but I’m uncertain how to approach the iOS side as their SDK depends on other Cocoapod pods.

If possible I would like to design my plugin so that users can simply link to it using the typical process.

For example
$ npm i react-native-myplugin --save
$ react-native link react-native-myplugin

If I create a Podfile and install the dependencies Cocoapods is going to create a XCode workspace. As far as I can tell all react native modules are linked into an iOS project using a .xcodeproj and not a workspace.

Is there a way to include cocoapods in a native module plugin?

Thanks!!

-Nick


(Aaron Brager) #2

If you want to use CocoaPods you will need to embed the project in a workspace (CocoaPods does this for you and it works fine with React Native). You could also look at Carthage or Buck as alternatives.