Flutter
iOS
error resolution
Flutter/Flutter.h
troubleshooting

error 'Flutter/Flutter.h' file not found when flutter run on iOS

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

The error Flutter/Flutter.h file not found usually means the iOS side of a Flutter project is not resolving the generated Flutter framework through CocoaPods or the expected workspace files. The message looks like a compiler problem, but the root cause is typically build setup, not missing source code. In practice, the fix is to restore the generated iOS artifacts and make sure Xcode is opening the workspace that CocoaPods created.

What the Error Usually Means

On iOS, Flutter integrates native build settings, generated files, and CocoaPods-managed dependencies. If any part of that chain is stale or skipped, Xcode cannot find the Flutter headers during compilation.

Common causes include:

  • opening Runner.xcodeproj instead of Runner.xcworkspace
  • not running pod install
  • stale Pods or Podfile.lock files after SDK changes
  • a broken generated .ios or Flutter folder in module-style projects
  • local environment issues with CocoaPods or Xcode command-line tools

The path to recovery is usually the same regardless of which of those caused the failure.

Standard Repair Flow

Start from the Flutter project root and regenerate the iOS build state:

bash
1flutter clean
2flutter pub get
3cd ios
4pod install
5cd ..
6flutter run

If CocoaPods reports an error, fix that first. The header problem often disappears once pods are installed correctly.

When opening the project manually in Xcode, use the workspace:

bash
open ios/Runner.xcworkspace

If you open Runner.xcodeproj, Xcode does not load the CocoaPods integration, which is one of the most common reasons Flutter/Flutter.h appears missing.

Resetting Broken iOS Artifacts

If the standard flow does not work, clear out iOS dependency artifacts and reinstall them:

bash
1rm -rf ios/Pods ios/Podfile.lock
2flutter clean
3flutter pub get
4cd ios
5pod install --repo-update
6cd ..
7flutter run

This is useful after:

  • upgrading Flutter
  • changing plugin versions
  • switching Xcode versions
  • pulling a branch with inconsistent generated files

For add-to-app or module setups, regenerate the platform-specific artifacts if needed:

bash
flutter pub get
flutter precache --ios

In some project layouts, the generated Flutter files are not committed and must be recreated locally.

Verifying the iOS Toolchain

Sometimes the real problem is the local toolchain rather than the project itself. Run:

bash
flutter doctor -v

Pay close attention to:

  • Xcode installation status
  • CocoaPods availability
  • accepted Xcode license
  • iOS simulator and command-line tools configuration

If CocoaPods is missing or broken, reinstalling it can unblock the build. On many systems:

bash
sudo gem install cocoapods
pod repo update

If your environment uses Homebrew or another Ruby setup, use the installation method already standard for that machine.

Xcode Build Settings to Check

If the project still fails inside Xcode after pods install successfully, inspect a few integration points:

  • 'ios/Flutter/Generated.xcconfig should exist.'
  • The Pod targets should appear in the workspace.
  • 'Podfile should not contain accidental manual edits that removed Flutter integration.'
  • Custom header search path changes should be treated with suspicion.

A simple Podfile for a normal Flutter app should leave most Flutter-generated wiring alone. If someone manually modified pod targets or build settings, compare against a fresh Flutter project.

When the Error Happens in CI

CI builds often fail with this message when the workflow skips flutter pub get, does not run CocoaPods, or caches stale pod directories across Flutter upgrades. Make sure the pipeline performs the same setup a local machine needs.

bash
1flutter pub get
2cd ios
3pod install
4xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphonesimulator build

The important part is that CI should build the workspace, not the plain project file.

Common Pitfalls

The biggest mistake is opening Runner.xcodeproj instead of Runner.xcworkspace. That bypasses the pod integration entirely.

Another common issue is running flutter clean and flutter pub get but forgetting pod install. Flutter regenerates Dart-side artifacts, but iOS pods still need to be resolved.

Developers also sometimes delete parts of the ios/Flutter directory manually. Those generated files are part of the build chain and should usually be recreated by Flutter rather than hand-edited.

Finally, be careful with old caches after upgrading Flutter or Xcode. A stale pod setup can survive longer than expected and keep reproducing the same header error.

Summary

  • 'Flutter/Flutter.h errors usually point to broken iOS integration, not a missing source file.'
  • Run flutter clean, flutter pub get, and pod install before deeper debugging.
  • Open ios/Runner.xcworkspace, not Runner.xcodeproj.
  • If needed, remove Pods and Podfile.lock and reinstall dependencies.
  • Check flutter doctor -v and verify the local CocoaPods and Xcode setup.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.