Skip to content

Instantly share code, notes, and snippets.

@aklehm
Last active September 10, 2025 08:03
Show Gist options
  • Select an option

  • Save aklehm/fdc7fd917a13758677e8c4e3f4434dfe to your computer and use it in GitHub Desktop.

Select an option

Save aklehm/fdc7fd917a13758677e8c4e3f4434dfe to your computer and use it in GitHub Desktop.
Flutter iOS to release build

Description

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-only

To simplify this workflow, the provided shell script automates the following steps:

flutter clean
flutter pub get
flutter build ios --release --config-only

This 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.

Global Installation Guide

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.

1. Save the script

Create a file named fclean.sh and paste the script content into it.

2. Make the script executable

chmod +x fclean.sh

3. Move the script to a directory in your PATH

For example, move it to /usr/local/bin (this directory is usually included in the PATH by default):

sudo mv fclean.sh /usr/local/bin/fclean

Note: Renaming it to fclean (without .sh) makes it easier to call.

  1. Verify the installation

Run inside your flutter project folder:

fclean

You should see the script executing (flutter clean, flutter pub get, and flutter build ios --release --config-only).

#!/bin/bash
set -e
echo "Flutter clean..."
flutter clean
echo "Flutter pub get..."
flutter pub get
echo "Flutter build ios --release --config-only..."
flutter build ios --release --config-only
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment