Facing the frustrating error message "CocoaPods could not find compatible versions for pod "PhoneNumberKit/PhoneNumberKitCore"" while working on your iOS project? You're not alone. This issue has been encountered by many developers using CocoaPods and the PhoneNumberKit library.
The good news is that there's a solution. Let's dive into the details and help you resolve this issue:
The Root Cause:
The issue stems from a mismatch between the PhoneNumberKit library version supported by the flutter_libphonenumber
package and the latest version available on GitHub. Specifically, the flutter_libphonenumber: 2.1.4
documentation directs users to add the following line to their Podfile:
pod 'PhoneNumberKit', :git => 'https://github.com/marmelroy/PhoneNumberKit'
However, the GitHub repository for PhoneNumberKit has introduced a new release (version 3.6.5), while the flutter_libphonenumber
package only supports up to version 3.6.0.
Temporary Solution:
To resolve the dependency issue temporarily, you can create a repository containing the source files for PhoneNumberKit version 3.6.0. Here's how:
- Create a new GitHub repository.
- Clone the PhoneNumberKit repository and checkout the 3.6.0 tag.
- Add the source files from the 3.6.0 tag to your new repository.
- Push the changes to your new repository.
Once you have created your repository, update your Podfile to point to your new repository:
pod 'PhoneNumberKit', :git => 'https://github.com/BTonny/PhoneNumberKit-3.6.0'
This should resolve the dependency issue for you temporarily. However, it's important to note that this is a temporary solution. The flutter_libphonenumber
team will eventually resolve this issue, and you'll be able to revert to the original repository.
Alternative Solution:
Another solution that has worked for some developers is to change the version of the phone_number
dependency in the pubspec.yaml
file. Try updating the version to phone_number: ^1.0.0
and see if that resolves the issue for you.
We hope these solutions help you resolve the CocoaPods dependency issue related to PhoneNumberKit. If you have any further questions or encounter any difficulties, feel free to leave a comment below.