1

I'm following instructions here to add a package: https://github.com/joltup/rn-fetch-blob It says to do npm install OR add to Podfile. What I did was

yarn add rn-fetch-blob

Then 

cd ios
pod install

Is that correct? I didn't edit the Podfile but somehow it still knew to get the dependency. Output:

Analyzing dependencies
Downloading dependencies
Installing rn-fetch-blob (0.12.0)
Generating Pods project
Integrating client project

The Podfile doesn't have any reference to rn-fetch-blob. Can someone explain if I did it right or if I needed to edit the Podfile?

Joshua Augustinus
  • 1,468
  • 3
  • 15
  • 28

2 Answers2

3

When you do pod install, it actually looks into your package.json dependancies to see what dependency requires pod installation. As you have already added it to node_modules but not in Podfile.

Utonium
  • 474
  • 4
  • 10
2

Assuming that you are using the latest React Native version like 0.60 and above, this process is simply called Autolinking

Basically, whenever you add a new library to your package.json as you did for rn-fetch-blob and run pod install after adding it, the whole node_modules folder is being scanned thanks to a script file called native_modules.rb to find an appropriate podspec file and install what is necessary to install a pod.

This is the definition of how iOS auto-linking works from the community docs:

Platform iOS

The native_modules.rb script required by Podfile gets the package metadata from react-native config during install phase and:

Adds dependencies via CocoaPods dev pods (using files from a local path). Adds build phase scripts to the App project’s build phase. (see examples below) This means that all libraries need to ship a Podspec either in the root of their folder or where the Xcode project is. Podspec references the native code that your library depends on.

Nostromo
  • 959
  • 2
  • 7
  • 25