Skip to content

Xcode Archive Fails with "Improperly formatted define flag" Error in Flutter 3.38.0 #178452

@alihamza0173

Description

@alihamza0173

Steps to reproduce

  1. Create a Flutter project with iOS support
  2. Add CocoaPods dependencies (Firebase, etc.)
  3. Run pod install in the ios directory
  4. Open the project in Xcode
  5. Attempt to archive the project (Product → Archive)
  6. Build fails with "Improperly formatted define flag" error

Expected results

The archive should complete successfully, as it does in Flutter 3.35.7.

Actual results

Archive build fails with the following error:

Improperly formatted define flag: Failed to package /path/to/project.
Command PhaseScriptExecution failed with a nonzero exit code

The error occurs during the "Run Script" build phase that executes:

/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build

Build Log Details

The build log shows that OTHER_SWIFT_FLAGS and GCC_PREPROCESSOR_DEFINITIONS are being expanded with leading spaces:

export OTHER_SWIFT_FLAGS\=\ -DCOCOAPODS
export GCC_PREPROCESSOR_DEFINITIONS\=\  COCOAPODS=1 ...

Note the double space after the = sign, which appears to be causing the Flutter build script to fail.

Additional Context

  • No code changes were made between testing 3.35.7 and 3.38.0
  • The issue appears to be related to how Flutter 3.38.0's xcode_backend.sh script processes build settings with define flags
  • The error specifically occurs during the archive process, not during regular builds
  • The project uses CocoaPods with dependencies including Firebase, VeriffSDK, and other iOS frameworks

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
Improperly formatted define flag: Failed to package /path/to/project.
Command PhaseScriptExecution failed with a nonzero exit code

The error occurs during the "Run Script" build phase that executes:

/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build

Build Log Details

The build log shows that OTHER_SWIFT_FLAGS and GCC_PREPROCESSOR_DEFINITIONS are being expanded with leading spaces:

export OTHER_SWIFT_FLAGS\=\ -DCOCOAPODS
export GCC_PREPROCESSOR_DEFINITIONS\=\  COCOAPODS=1 ...

Note the double space after the = sign, which appears to be causing the Flutter build script to fail.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.38.0, on macOS 26.1 25B78 darwin-arm64, locale
    en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.1.1)
[✓] Chrome - develop for the web
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work listplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: xcode"xcodebuild" on iOS and general Xcode project managementteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions