Do we need to run `pod install` with React Native 0.60?
Asked Answered
M

1

13

I'm using React Native 0.60.5 and am linking this module. It says that for React Native 0.60+, "CLI autolink feature links the module while building the app", so all we need to run is yarn add @react-native-community/async-storage.

However, on the main page describing autolinking it says that we need to run:

yarn add @react-native-community/async-storage cd ios && pod install && cd ..

What I Want To Know:

Do we have to run pod install for all native modules with React Native 0.60+?

Macleod answered 13/9, 2019 at 20:24 Comment(5)
After installing each native library that needs to link, you have to run pod install command.Yecies
I thought that pod install just linked the native module, and that that's what auto-linking was accomplishing automatically. What am I missing here?Macleod
Some will get auto-linked, others will add the dependency inside pod and you'll have to install emOshea
@Oshea So some native modules will get auto-linked, whereas others won't get auto-linked but will add a dependency in my Podfile, and I should do pod install to link them? If one of them gets auto-linked and then I try to manually link it with pod install as well, would that do nothing since it was already auto-linked?Macleod
Any react native library that uses a native iOS library will need pod installAgoraphobia
B
7

There are 2 types of linking in react-native

1 ) Manual linking

2 ) Pod linking

As described in official site

"If your iOS project is using CocoaPods (contains Podfile) and linked library has "podspec file", then react-native link will link library using Podfile."

Now when you

 react-native link

If you project has CocoaPods (contains Podfile) and linked library has podspec file then it will add pod path of linked library in podfile like this

pod 'RNImageCropPicker', :path =>  '../node_modules/@react-native-community/async-storage'

But you still have to run pod install command

If project does not have pod file or linked library does not have podspec file then you have to do manual linking as described in site

Now coming to question from react-native 0.60 this process is now automatic. You do not have to run "react-native link " . It will automatically do pod work for you when you install library using npm/yarn but still you have to run "pod install" command

Breadstuff answered 14/9, 2019 at 6:57 Comment(5)
When I do manual linking, I drag the .xcodeproj file to the Libraries folder, then drag the .a file from the .xcodeproj file to the "Link binary with libraries" section. Is this the 'linking' process that pod install does? In other words, if I manually link like this, is there any benefit to doing pod install?Macleod
I think the benefit of pod install is that you do not have to do any thing thing manually, Just run command and all done , on other hand you have to do all manual stepsBreadstuff
So am I correct that all that react-native link does (pre-React Native 0.60) is add a line for the module to your Podfile, and then you have to do pod install yourself? In other words, with auto-linking, all it does is automatically add the line to your Podfile so you don't have to, but you still have to run pod install? Second question, when I manually linked before, I dragged the .xcodeproj and .a files into their corresponding spots in XCode. Is that all that pod install does?Macleod
And last question (thanks for your patience), in the last year, I've never used pod install. I just ran react-native link and this successfully linked some modules, but not all. The ones that it didn't link, I linked manually. So it seems as though react-native link was doing more than just adding a line to my Podfile (which I never used); it was actually linking modules. Any idea what was happening there? Thanks again!Macleod
Just to be sure: if I'm opting to use pod install, the pod linking will also take care of dependencies and linking on the Android side of things, is that correct?Stupe

© 2022 - 2024 — McMap. All rights reserved.