This is still something that is required, I see this message all the time, but it's completely invalid from what I have experienced. Almost every package I work with, I still have to run the react-native link.
Can anyone tell me what's up with this? Is it just particular packages, or why do I still need to run react-native link all the time, when it tells me I shouldn't run it. I mean, it's really just adding it to the pod file for iOS and gradle for Android.
Anyone else experiencing this?
To show this further, look at this, just ran the npm install for lottie, it will not work unless I run the link, should I add to my pod file manually? I don't get why React Native (Facebook) team is saying that it's no longer required, out of our team of 4 people, we have had it required always.
Starting with version 0.60 React Native provides auto-linking.
That means if a library supports auto-linking all you have to do is install the library with
yarn
ornpm
, runpod install
in the ios folder and build.By example https://github.com/react-native-geolocation/react-native-geolocation supports auto-linking and you don't need it in the
Podfile.
(unless you have a very old version of it).In your case all the libraries listed in the print-screen as manually linked were added manually using
react-native link <libraryName>
or manually inside the Podfile or using a reference to a.xcodeproj
file inside Xcode.To remove those errors:
Make sure you have a library version that supports auto-linking and run
react-native unlink <libraryname>
andpod install
Note: to avoid some problems I found that sometimes its better to remove the
podfile.lock
and generate a new one with thepod install
If that doesn't work follow the steps from below:
1) Remove the lines in Podfile associated with those libraries (unless the library version that you have doesn't support auto-linking, in that case you should just run use manual linking as mentioned in the library docs).
You can check how a Podfile looks for a specific RN version by taking a look in the RN upgrade helper:
https://react-native-community.github.io/upgrade-helper/?from=0.59.5&to=0.63.3
2) You should not need now manual references in Xcode for libraries that support auto-linking (unless the library requires some special step mentioned in its docs).
This is how manual linking used to be done:
Source and more info here: https://reactnative.dev/docs/linking-libraries-ios
For the libraries that support auto-linking to avoid any errors you could remove the references(
.xcodeproj
and others) in Xcode associated with them (unless the associated library requires the modifications in Xcode)Sources and some useful links:
https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
https://medium.com/@srbkrishnan/react-native-auto-linking-on-android-65a850bb9ed9
Additional notes about the RN upgrade: I found that if there are too many things to modify in my
project.pbxproj
file at an upgrade, it was easier for me to start with a brand newproject.pbxproj
file taken directly from the RN upgrade helper. Then I replacedRnDiffApp
withMyProjectName
in that file and added the library modifications that I needed in Xcode one by one.