'Module not found issue with package installed in flutter module (add-to-app)
I have flutter module added to the existing iOS app. Not all but few of the packages installed (via pubspec.yaml file) could not be found by the iOS app when compiled, and I'm getting 'Module not found' error in XCode. Those problematic packages are: razorpay_flutter, google_maps_flutter, webview_flutter, and url_launcher until now. Please have a look at screenshot below:
Same is the case with other 3 packages.
Steps to reproduce issue:
- Add
razorpay_flutter: ^1.1.3in the pubspec.yaml file of the flutter module - Run
flutter pub get. The package will install - Run Xcode project to which flutter module is added. Got error!
One more thing I observed after step 2, that there is some warning regarding issue for add to existing app:
Running "flutter pub get" in lib_smazing...
The plugin `razorpay_flutter` is built using an older version of the Android plugin API which assumes that it's running in a full-Flutter environment.
It may have undefined behaviors when Flutter is integrated into an existing app as a module.
The plugin can be updated to the v2 Android Plugin APIs by following https://flutter.dev/go/android-plugin-migration.
I guess there is issue with the packages using platform channel/code when added to an existing app, but not sure whether its package-specific issue or a flutter issue with add-to-app.
Solution 1:[1]
After few trials and error I found simply running pod install on iOS project directory fixed the issue.
Solution 2:[2]
Rather trivial but realized my packages were not found because I opened and executed the wrong file in XCode - so open Runner.xcworkspace and not Runner.xccodeproj
Solution 3:[3]
There are multiple solutions available for any kind of library/module not found.
Solution # 1
flutter clean
flutter run again rebuild it from ios or vscode tool again.
if still problem
pod update
pod repo update
pod install
Solution# 2
delete build folder
delete pod.lock file
delete .syslinks folder
delete pods folder
change your directory in your terminal by
cd ios
pod install --repo-update OR pod repo update
pod install
flutter clean
flutter pub get
Solution# 3
please open Runner.xcworkspac with xcode because app will get local lib from pod install lib that installed. , but don't Runner.xcodeproj
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | iAkshay |
| Solution 2 | Hez |
| Solution 3 | Hamza Muazzam |

