Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't the Pod dependency manager detect the necessary modules for installation?

So this question is a follow up to my previous question: How can different apps import from a shared components folder? react / react-native

So I've created my own npm module which I store all my components in. These components can be used by as many apps as I like. Because I will be making those components highly reusable.

But I still have stumbled upon a problem.

I have created a loading component which uses this library: @react-native-community/masked-view. This library needs to install a dependency inside /ios/Podfile. First I created this component inside one of the react-native projects.

yarn add @react-native-community/masked-view
..
success Saved 1 new dependency.

cd ios/
pod install
..
Installing RNCMaskedView (0.1.6)
Pod installation complete! There are 33 dependencies from the Podfile and 31 total pods installed.

'

So then I ran my code, and the Loading component works. Now I want to add this to the NPM module (that, again, I created myself) which will contain all my components.

So I go into /my-awesome-99-components/ which has its own package.json since it is a module which I will import in each project I'm working on.

In /my-awesome-99-components/

yarn add react react-native @react-native-community/masked-view
..
success Saved 1 new dependency.

// Created Loading.js - this is the loading component

yarn publish
..

In /react-native-project-1/

yarn add my-awesome-99-components
..
Done in 3.17s.

cd ios/
Pod install
..

This is where the problem comes up. Now the Podfile won't install the RNCMaskedView because apparently my module doesn't let the project know that it should install some packages inside the ios/Podfile.

Does anyone know why this happens, and what would be the best solution for this?

I appreciate all the help!

like image 630
Steven Soekha Avatar asked Nov 07 '22 10:11

Steven Soekha


1 Answers

Have you tried adding a podspec file to your repo?

You can modify the podspec file from the masked-view package like

require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
  s.name         = "RNCMaskedView"
  s.version      = package['version']
  s.summary      = package['description']

  s.authors      = package['author']
  s.platforms    = { :ios => "9.0", :tvos => "9.0" }

  s.source       = { :git => "https://github.com/react-native-community/react-native-masked-view.git", :tag => "v#{s.version}" }
  s.source_files  = "node_modules/@react-native-community/masked-view/ios/**/*.{h,m}"

  s.dependency 'React'
end

only change here would be the path of the source files

like image 162
LonelyCpp Avatar answered Nov 12 '22 21:11

LonelyCpp