Is it possible to use cocoapods
when using React Native
?
If so, How can I require
in JavaScript the pods
projects?
Thanks in advance!
React Native uses Cocoapods to add iOS dependencies when you add new modules to your application. Cocoapods is a dependency manager for the Apple development ecosystem.
CocoaPods allows you to add code to run before and at the end of the Podfile via installation hooks. You probably already have some custom code in there. This plugin allows all that code to be centralized and reasoned about in a single place per React Native version.
I would suggest you install CocoaPods using brew . It's a little cleaner option and you can update it easier. The cocoapods cask is for CocoaPads App and the formula is for the CLI only version.
Yes. It's possible. React Native project is pretty much normal iOS application (In terms of XCode required to build it and quite a lot of React Native internal code is well... Native Obj-C). Since React Native project is already run via xcworkspace, so it's perfectly possible to add Obj-C pods to the ReactNative project.
Since a lot of dependencies used by RN apps are pure javascript rather than Obj-C code, it's more than convenient to keep both dependency systems - Cocoapods (for Obj-C dependencies) and npm (for javascript). Pods are kept in "Pods" directory and npm under "node-modules" and they are not clashing with each other. And it's pretty convenient actually to have different types of dependencies run by different dependency management systems.
UPDATE: by default ReactNative project is .xcodeproj based, but it's easy to convert it to .xcodeworkspace.
I even tried to add React Native itself as Cocoapods dependency and it was sort of working (but some dependencies expected React in the "node-modules" dir so I abandoned it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With