I’m currently facing a dependency conflict in my React Native project when trying to use both react-native-image-crop-picker and react-native-image-crop-tools. Each library depends on different versions of TOCropViewController, leading to a conflict that I’m unable to resolve.
Here’s the situation:
- [email protected] does not specify a version for [email protected]
- [email protected] explicitly requires [email protected].
- When I install react-native-image-crop-picker first and then run pod install in the ios directory, it succeeds. However, after adding react-native-image-crop-tools and running pod install again, I encounter the following error:
[!] CocoaPods could not find compatible versions for pod "TOCropViewController":
In snapshot (Podfile.lock):
TOCropViewController (= 2.6.1)
In Podfile:
RNImageCropPicker (from `../node_modules/react-native-image-crop-picker`) was resolved to 0.40.3, which depends on
TOCropViewController
react-native-image-crop-tools (from `../node_modules/react-native-image-crop-tools`) was resolved to 1.6.4, which depends on
TOCropViewController (= 2.5.3)
I understand this is a basic dependency conflict so i added pod ‘TOCropViewController’, ‘2.5.3’ in Podfile. But it is not still working.
How to solve this?
Any advice is welcome. Thank you
2
Answers
I noticed that the react-native-image-crop-picker utilizes version 2.6.1 of TOCropViewController, which introduces a property not present in version 2.5.3. Since react-native-image-crop-tools was using the latter version, this incompatibility prompted me to update the TOCropViewController version in the react-native-image-crop-tools.
Specifically, I changed the dependency version in the podspec located at
node_modules/react-native-image-crop-tools/react-native-image-crop-tools/podspec
from:s.dependency 'TOCropViewController', '2.5.3' => s.dependency 'TOCropViewController', '2.6.1'
If it is necessary to use those two packages, you can try manually to adjust the version TOCropViewController inside react-native-image-crop-picker, until it is working as expected or directly disable it, if it possible. Then using https://www.npmjs.com/package/patch-package you can apply your changes to the patch every time you install/update your node modules. Keep in mind this is a solution where the two packages are a must.