gran33
gran33

Reputation: 12991

React Native using Cocoapods

Is it possible to use cocoapods when using React Native?

If so, How can I require in JavaScript the pods projects?

Thanks in advance!

Upvotes: 14

Views: 4940

Answers (1)

Jarek Potiuk
Jarek Potiuk

Reputation: 20107

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

Upvotes: 7

Related Questions