Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Cocoapods: Add react native dependency in Podspec

$
0
0

How can I make my cocoapod dependent on react native (0.63 using the new React-Core pod)?

This is my situation:

I am building a framework which uses react native internally. I want to distribute this framework using Cocoapods.

My library exposes a single UIViewController which starts the React Native bridge and loads Bundle.js which contains all of the apps code.

In my Podspec, I have added the following:

 s.source_files   = 'Pod/Classes/**/*.{h,m}' s.resources      = 'Pod/Assets/{Bundle.js,assets}' s.dependency 'React-Core', react_native_version

In my example app's Podfile, I import my library like this:

pod 'MyLibrary', path: 'path/to/library/on/disk'

However, using this configuration pod install fails to find React-Core.

So I added the following to the Podfile:

require_relative '../node_modules/react-native/scripts/react_native_pods.rb'require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'...config = use_native_modules!use_react_native!(:path => config["reactNativePath"])

This works. However, it would be better if I don't need to do this in the Podfile, because the user then needs to remember to install react native. Can I somehow tell the Podspec to package react native into my package, so that I don't need to deal with it in the Podfile?


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>