I've been working with flutter for a while now and I've run into my share of build problems. These happen fairly frequently when building production versions of my application or after upgrading to a new flutter version.I've found it useful to keep track of issues i've encountered to prevent time lost debugging issues i've already run accross in the past. I've experienced the most issues with iOS so this post will focus on that platform.
Before debugging build issues it's typically helpful to start by peforming a clean
$ flutter clean
If that doesn't work a deep clean which clears the xcode and flutter build cache may help.
$ rm -rf $HOME/Library/Developer/Xcode/DerivedData/* $ rm -rf $HOME/Library/Flutter/bin/cache/* $ rm -rf app/ios/Flutter/App.framework ios/Flutter/Flutter.framework $ rm -rf app/build $ rm -rf app/.packages $ rm -rf app/.flutter-plugins
I usually follow this up with a
pod install in the iOS project to update necessary dependencies.
If this doesn't work then it's time to roll up your sleeves and really dive into the issue. This is a collection that I've found that I frequently run into recently presented in no particular order.
When uploading to the App Store, you get
"Invalid Bundle. The bundle Runner.app/Frameworks/App.framework does not support the minimum OS Version specified in the Info.plist."
This may be the result of setting a minimum version in your
Podfile. Updating the apps minimum OS version in the
AppFrameworkInfo.plistmay resolve the issue.
You may also need to update your iOS deployment target to match.
Attempting to build your iOS bundle fails with a clean build with the error
.../Release-iphoneos/Runner.build/Script-66F40DDC22E81E8000FC45EE.sh: line 3: /.../actions-runner/_work/yourapp/yourapp/app/ios/Pods/Fabric/run: No such file or directory
This is caused by the Flutter Firebase plugin's update to Crashlytics, you will need to migrate the integration by following instructions in the migration guide.
Attempting to build an iOS bundle fails with
error: Runner.app/Info.plist does not exist. The Flutter "Thin Binary" build phase must run after "Copy Bundle Resources".after upgrading your flutter version
flutter cleanshould resolve this. If you have customizations in your xcode project settings you may attempt to reset them with
flutter create -i swift .then reapply your customizations.
Attempting to build your app results in similar errors building protobufs for flutter.
/Users/user/Developer/yourapp/app/ios/Pods/Protobuf/objectivec/GPBUtilities.h:34:9: warning: double-quoted include "GPBMessage.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header] #import "GPBMessage.h" ^~~~~~~~~~~~~~ <GPBMessage.h> /Users/user/Developer/yourapp/app/ios/Pods/Protobuf/objectivec/GPBUtilities.h:35:9: warning: double-quoted include "GPBRuntimeTypes.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header] #import "GPBRuntimeTypes.h" ^~~~~~~~~~~~~~~~~~~ <GPBRuntimeTypes.h>
This was allegedly the result of a bug introduced in cocoapods. Updating to the latest version
sudo gem install cocoapods should resolve the issue. If you have a
Gemfile.lock those would need to be updated as well with
- Attempting to build your app after upgrading your flutter version results in an error message similar to the following.
Launching lib/main.dart on iPhone 11 Pro Max in debug mode... Warning: Podfile is out of date This can cause a mismatched version of Flutter to be embedded in your app, which may result in App Store submission rejection or crashes. If you have local Podfile edits you would like to keep, see https://github.com/flutter/flutter/issues/24641 for instructions. To regenerate the Podfile, run: rm ios/Podfile Running Xcode build... Xcode build done. 7,8s Failed to build iOS app Error output from Xcode build: ↳ ** BUILD FAILED ** Xcode's output: ↳ /Users/user/developer/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/ios/Classes/CloudFirestorePlugin.m:155:24: error: no visible @interface for 'FIRQuery' declares the selector 'queryWhereField:arrayContainsAny:' query = [query queryWhereField:fieldName arrayContainsAny:value];
This may be because your
Podfile is out of date. Performing a clean and deleting your
Podfile will allow the flutter build process to regenerate one.
flutter clean rm -Rf ios/Pods rm -Rf ios/.symlinks rm -Rf ios/Flutter/Flutter.framework rm -Rf ios/Flutter/Flutter.podspec rm ios/Podfile flutter build