When using Flutter 3.22+ (including 3.35.1) on macOS, developers may encounter the following issue when trying to create an archive in Xcode:
Your Flutter project is currently configured for debug mode.
Please run `flutter build ios --config-only --release` in your Flutter project to update your settings.
This happens because Flutter regenerates ios/Flutter/Generated.xcconfig with
FLUTTER_CLI_BUILD_MODE=debug after commands like flutter clean or flutter pub get.
As a result, even if the Xcode scheme is set to Release, the project may still be treated as Debug until you manually run:
flutter build ios --release --config-onlyTo simplify this workflow, the provided shell script automates the following steps:
flutter clean
flutter pub get
flutter build ios --release --config-onlyThis ensures that the iOS build configuration is always correctly set to Release before archiving.
You can keep this script in your Flutter project (e.g., fclean.sh) or install it globally as a custom command, making it faster and less error-prone to prepare your project for App Store submission.
You can make the script available as a global command on macOS so you can run it from any Flutter project without copying it each time.
Create a file named fclean.sh and paste the script content into it.
chmod +x fclean.shFor example, move it to /usr/local/bin (this directory is usually included in the PATH by default):
sudo mv fclean.sh /usr/local/bin/fcleanNote: Renaming it to fclean (without .sh) makes it easier to call.
- Verify the installation
Run inside your flutter project folder:
fcleanYou should see the script executing (flutter clean, flutter pub get, and flutter build ios --release --config-only).