Flutter iOS构建失败求助:firebase_auth模块未找到
Context
I know exactly how frustrating this is—you fixed your Flutter dependency issues on Windows by switching to CodeMagic, but now when running the iOS build command:
/usr/local/bin/flutter build ios --debug --no-codesign
Xcode throws an error pointing to line 10 of /Users/builder/clone/ios/Runner/GeneratedPluginRegistrant.m, saying it can't find the firebase_auth module, killing the build entirely.
Proven Solutions to Try
Let's walk through the most common fixes for this specific CodeMagic + Flutter + Firebase scenario:
1. Validate Your Flutter Firebase Dependency Setup
First, double-check your pubspec.yaml to ensure firebase_auth is correctly declared and compatible with other Firebase plugins (like firebase_core, which is required):
dependencies: flutter: sdk: flutter firebase_core: ^2.24.2 # Use a version compatible with your firebase_auth firebase_auth: ^4.16.0 # Stick to a stable, compatible release
Add a flutter pub get step to your CodeMagic pre-build script to ensure dependencies are pulled fresh every time.
2. Wipe CodeMagic's Build Cache & Reset iOS Dependencies
Cached build artifacts in CodeMagic often cause stale plugin references. Here's how to fix it:
- In your CodeMagic build configuration, enable Clear build cache before build under the Build Cache section
- For a deeper reset, add this pre-build script to clean up iOS-specific files:
cd ios rm -rf Pods Podfile.lock Runner/GeneratedPluginRegistrant.* pod deintegrate pod repo update
3. Confirm iOS Firebase Configuration is Complete
Don't overlook the basics:
- Make sure your
GoogleService-Info.plist(downloaded from Firebase Console) is placed in theios/Runnerdirectory and added to your Xcode project target (not just copied into the folder) - Check your
ios/Podfilehas the correct minimum iOS version and framework settings:platform :ios, '12.0' # firebase_auth requires iOS 12.0+ use_frameworks! # Required for some Firebase plugins with Flutter 2.0+
4. Regenerate the Plugin Registrant File Manually
Sometimes GeneratedPluginRegistrant.m doesn't update correctly. Fix this locally first, then push the changes:
flutter clean flutter pub get flutter build ios --debug --no-codesign
Commit the updated GeneratedPluginRegistrant.m to your repo, then re-run the CodeMagic build.
5. Match CodeMagic's SDK Versions to Your Local Setup
Mismatched Flutter or Xcode versions can break plugin compatibility:
- In CodeMagic's build configuration, select the same Flutter SDK version you use locally
- Ensure CodeMagic uses an Xcode version that supports your Firebase plugin (e.g., newer
firebase_authversions require Xcode 14.0+)
Verification Step
After applying any of these fixes, trigger a new CodeMagic build. If the error persists, check the pod install output in the build logs—this will tell you if firebase_auth was actually installed correctly.
内容的提问来源于stack exchange,提问作者Daniele Angelini




