I have flutter’s app. I run it app in debug mode on iPhone from Android Studio(on Mac). It is very slowly(about 10 minutes). if I run my project from xCode it is much faster – about a minute.
this is a "medium" project, it uses some firebase packages:
firebase_messaging: ^10.0.3
firebase_analytics: ^8.1.2
firebase_remote_config: ^0.10.0+2
firebase_core: ^1.3.0
but I did not find any problems on the net related to these plugins, only for cloud_firestore.
how can I determine what is the problem with the long build? any advice?
2
Answers
I solved this problem - new Mac Mini(M1/8 Gb). the first build can last 40-50 seconds (10 times faster). next build - of 10-25 seconds.
There are several ways to speed up the build process for an iOS app in Flutter:
Use the profile build mode: By default, Flutter builds in the debug mode, which includes additional features for debugging and development. However, building in the profile mode can significantly speed up the build process. You can switch to the profile build mode by running the command
flutter build ios --profile
.Enable AOT compilation: Ahead-of-Time (AOT) compilation can improve the performance of your app by compiling the Dart code to machine code before it’s run. You can enable AOT compilation by running the command
flutter build ios --release --no-codesign
.Use
flutter build
command instead offlutter run
: Theflutter run
command is convenient for development, but it’s slower than theflutter build
command because it includes additional features like hot reloading and debugging.Use
flutter build bundle
command: flutter build bundle command generates an asset bundle for your app, including all the resources like images, fonts, and JSON files. This command is faster than flutter build command because it only build the necessary asset, not the entire app.Reduce the size of your app: Remove unnecessary assets, libraries and classes that are not used in your app. You can use
flutter analyze
command to detect any unnecessary parts in your code.Clean and rebuild: Sometimes the build process can be slow due to stale files or cached data. Running the
flutter clean
command and then rebuilding can help speed up the process.Use a Mac with more powerful hardware: Building for iOS requires a Mac, and building time can be affected by the performance of the Mac you are using. If you are using a Mac with lower performance, you can try building on a more powerful Mac or using a cloud-based Mac build service like Bitrise or CircleCI
It’s also good practice to keep your Flutter SDK and Xcode updated to the latest version to take advantage of performance improvements.