Flutter 2.5.1 – Could not build the application for the simulator

Issue

I migrated my project from Flutter 1 to 2.5.1, and I countered this error

Result:

In file included from
/Users/Jeremy/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.11/ios/Classes/FLT
URLLauncherPlugin.m:7:
/Users/Jeremy/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.11/ios/Classes/FLT
URLLauncherPlugin.h:5:9: fatal error: 'Flutter/Flutter.h' file not found

#import <Flutter/Flutter.h>
        ^~~~~~~~~~~~~~~~~~~

1 error generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Analyzing workspace
note: Constructing build description
note: Build preparation complete
note: Removed stale file
'/Users/Jeremy/Library/Developer/Xcode/DerivedData/Runner-bkrpcbgqxwmjkngadaeegdgrlbut/Build/Products/
Debug-iphonesimulator/share/share.framework'

note: Removed stale file
'/Users/Jeremy/Library/Developer/Xcode/DerivedData/Runner-bkrpcbgqxwmjkngadaeegdgrlbut/Build/Products/
Debug-iphonesimulator/flutter_keyboard_visibility/flutter_keyboard_visibility.framework'

note: Removed stale file
'/Users/Jeremy/Library/Developer/Xcode/DerivedData/Runner-bkrpcbgqxwmjkngadaeegdgrlbut/Build/Products/
Debug-iphonesimulator/sqflite/sqflite.framework'

note: Removed stale file
'/Users/Jeremy/Library/Developer/Xcode/DerivedData/Runner-bkrpcbgqxwmjkngadaeegdgrlbut/Build/Products/
Debug-iphonesimulator/geocoding/geocoding.framework'

note: Removed stale file
'/Users/Jeremy/Library/Developer/Xcode/DerivedData/Runner-bkrpcbgqxwmjkngadaeegdgrlbut/Build/Products/
Debug-iphonesimulator/package_info_plus/package_info_plus.framework'

note: Removed stale file
'/Users/Jeremy/Library/Developer/Xcode/DerivedData/Runner-bkrpcbgqxwmjkngadaeegdgrlbut/Build/Products/
Debug-iphonesimulator/google_sign_in/google_sign_in.framework'

note: Removed stale file
'/Users/Jeremy/Library/Developer/Xcode/DerivedData/Runner-bkrpcbgqxwmjkngadaeegdgrlbut/Build/Products/
Debug-iphonesimulator/connectivity_plus/connectivity_plus.framework'

note: Removed stale file
'/Users/Jeremy/Library/Developer/Xcode/DerivedData/Runner-bkrpcbgqxwmjkngadaeegdgrlbut/Build/Products/
Debug-iphonesimulator/Runner.app'

note: Removed stale file
'/Users/Jeremy/Library/Developer/Xcode/DerivedData/Runner-bkrpcbgqxwmjkngadaeegdgrlbut/Build/Products/
Debug-iphonesimulator/geolocator_apple/geolocator_apple.framework'

note: Removed stale file
'/Users/Jeremy/Library/Developer/Xcode/DerivedData/Runner-bkrpcbgqxwmjkngadaeegdgrlbut/Build/Products/
Debug-iphonesimulator/google_maps_flutter/google_maps_flutter.framework'

All of my package/plugins are updated to nullsafety version, and I also did delete the ios folder and created a new one using flutter create . and i still get the same result.

Solution

There are many reasons why this error occurs since you’ve migrated to Flutter 2.0 (null-safety).

You re-created the whole ios and/or android which will generate the new codes (or syntax) and files which might lead to an error like what you’re facing.

For anyone who are planning to migrate please always keep a backup file for your internal configs in ios and/or android folders respectively.

DON’T JUST DROP YOUR iOS and android FOLDER BACK!

You need to manually reconfig your files under those folders.
If you’re using Firebase packages, you can add these lines in your Podfile inside the clause target 'Runner' do:

# add the Firebase pod for Google Analytics
# or pod ‘Firebase/AnalyticsWithoutAdIdSupport’
# for Analytics without IDFA collection capability
# add pods for any other desired Firebase products
# https://firebase.google.com/docs/ios/setup#available-pods
  pod 'Firebase/Analytics'
  pod 'Firebase/DynamicLinks'

Follow some tips here

After that, make sure that you configured back other app’s metadata like AppBundleName and some permissions in info.plist

ANOTHER THING

(might be optional)
If you’re gonna check the pubspec.yaml, there’s a new line there which you need to add for new linting options. Pay attention to the spacing.

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^1.0.0

Then do what 99% stackoverflow users always says with this matter 🙂

delete pubspec.lock

delete pods folder

delete Podfile.lock

flutter pub cache repair

flutter clean

flutter pub get

Answered By – snap

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.