Xcode 16.4 archive fails with "unable to spawn process '/bin/sh' (Argument list too long)" in Flutter project
I'm getting this error when archiving my Flutter iOS app:
Error (Xcode): unable to spawn process '/bin/sh' (Argument list too long)
Environment:
- Xcode 16.4
- Flutter 3.38.7
- CocoaPods 1.16.2
- macOS (Darwin 24.4.0)
What I've tried:
- Cleaned DerivedData (rm -rf ~/Library/Developer/Xcode/DerivedData)
- Ran flutter clean and flutter pub get
- Removed ios/build and ios/Pods, then ran pod install
- Verified --dart-define-from-file config is small (~1.6KB)
- Verified environment variables are small (~2KB total)
Project details:
- 84 pods installed
- Uses Firebase, Sentry, OneSignal, Mixpanel, and other common SDKs
Build command: fvm flutter build ipa --flavor stage --target lib/main_stage.dart --dart-define-from-file=config_stage.json
Questions:
- Is this a known Xcode 16.4 issue?
- Are there workarounds for the ARG_MAX limit in Xcode build phases?
- Could any specific pod be contributing to this?
Any help appreciated.