重新克隆Flutter项目后iOS模拟器编译报错:'grpcpp/support/byte_buffer.h'未找到
Since you’ve already tried common solutions from Google, let’s dive into targeted fixes to resolve this build error:
Wipe Pods and Build Cache Entirely
Residual cache from your old setup is often the culprit. Run these commands in your project’siosfolder:pod deintegrate rm -rf Podfile.lock Pods rm -rf ~/Library/Caches/CocoaPods rm -rf ~/Library/Developer/Xcode/DerivedData pod installHead back to your project root, run
flutter clean, then tryflutter runagain.Align Firebase Package Versions
The error links to FirebaseFirestore’s dependency on gRPC. Double-check yourpubspec.yamlandios/Podfileto ensurefirebase_coreandcloud_firestoreare on compatible, up-to-date versions. Runflutter pub upgradeto sync dependencies, then re-runpod install.Explicitly Pin gRPC Version
Force a compatible gRPC version by adding this line to yourios/Podfile(before thetarget 'Runner' doblock):pod 'gRPC-C++', '~> 1.50.0' # Adjust to match your Firestore version's requirementsRun
pod installafterward to pull the correct library.Validate Xcode Header Paths
Open your iOS project in Xcode, navigate to the Runner target’s Build Settings, search for Header Search Paths, and confirm$(PODS_ROOT)/gRPC-C++/includeis listed (set to recursive). This ensures Xcode can find the missing gRPC headers.Fresh Clone with Clean Setup
If all else fails, clone the repo into a brand new directory—don’t carry over any old config files. Runflutter pub get, thencd ios && pod install, before attempting to build. This eliminates any leftover artifacts from your previous Mac setup.
Original Build Log:
Launching lib/main.dart on iPhone 12 in debug mode...
lib/main.dart:1
Xcode build done. 8,8s
Failed to build iOS app
Error output from Xcode build:
↳ ** BUILD FAILED **
Xcode's output:
↳ In file included from /Applications/MAMP/htdocs/capido/ios/Pods/FirebaseFirestore/Firestore/core/src/nanopb/writer.cc:17:
/Applications/MAMP/htdocs/capido/ios/Pods/FirebaseFirestore/Firestore/core/src/nanopb/writer.h:28:10: fatal error: 'grpcpp/support/byte_buffer.h' file not found
#include "grpcpp/support/byte_buffer.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 12.
Exited (sigterm)
内容的提问来源于stack exchange,提问作者Erwin Oudshoorn

