# Making flutter builds faster

**URL:** <https://discuss.bitrise.io/t/making-flutter-builds-faster/3976>\
**Category:** Question & Answer\
**Tags:** build-cache, flutter\
**Created:** [January 31, 2018, 1:11am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976 "2018-01-31T01:11:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ch\_kent](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@ch\_kent](https://discuss.bitrise.io/u/ch_kent)\
**Post date:** [January 31, 2018, 1:11am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/1 "2018-01-31T01:11:44Z")

</div>

Hi,

I’ve set up a flutter build and all is working fine for both iOS and Android. I was hoping to make the build a bit faster by leveraging caching. However, my attempts so far have just slowed things down. That’s because despite caching, the steps I was _hoping_ would be faster (such as installing flutter) are still the same. That is, they’re not using the cache to avoid the need to re-install.

Is there any guidance on setting up flutter with Bitrise in such a way as to avoid the ~3 mins required to simply install flutter on every build?

For the record, I tried caching these paths:

- /Users/vagrant/flutter/
- /Users/vagrant/.pub-cache/
- /usr/local/Cellar/
- /Users/vagrant/Library/Caches/Homebrew/

However, that was far too expensive (~4GB) and was recreating the cache every time due to irrelevant file changes. I also tried toning it right down to just:

- /Users/vagrant/flutter/

The cache was still approaching 1GB and it _would_ have been faster, except flutter still insisted on running a full install. My install script for flutter is:

```auto
    - script:
        title: Install flutter
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            cd ..
            git clone -b alpha https://github.com/flutter/flutter.git
            export PATH=`pwd`/flutter/bin:$PATH

            brew install --HEAD libimobiledevice
            brew install ideviceinstaller
            brew install ios-deploy

            flutter doctor

```

Thanks

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [February 1, 2018, 1:11pm UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/2 "2018-02-01T13:11:02Z")

</div>

Hi @ch_kent,

> [@ch\_kent](#):
>
> I also tried toning it right down to just:
> 
> /Users/vagrant/flutter/

Are you sure that’s where flutter installs its actual binaries? `bin/flutter` in the repository is just a script ([https://github.com/flutter/flutter/blob/master/bin/flutter](https://github.com/flutter/flutter/blob/master/bin/flutter)). Not sure where the actual binary is / what should be cached. That always depends on the tool, what worth to cache and which dir(s) should be cached.

Additionally, if most of the flutter install is downloading some pre-compiled binaries then the cache might not even worth it at all, as the cache have to be downloaded as well, which will most likely take about the same time than just downloading from the official source. E.g. `brew` by default downloads precompiled tools, meaning `brew install` usually can’t be made faster as it just downloads the binaries/components.

Typically the best candidates for caching are the files/dirs which you can’t just download from an official source but have to be built locally. There you trade the compile time for cache download, which usually is faster, but this also depends on the tool, how fast or slow the compile of the tool is vs the size of the compiled files.

I’m not saying flutter can’t be cached, just wanted to share a couple of notes / things to consider. Unfortunately we’re not familiar with how flutter install works (what would worth or not worth to cache), you might want to ask that on flutter’s forums/support.

Of course if you’d have any questions just let us know! 🙂

---

<div class="post-metadata">

**Author:** ![koral](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/koral/32/357_2.png) [@koral](https://discuss.bitrise.io/u/koral)\
**Post date:** [April 23, 2018, 4:36pm UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/3 "2018-04-23T16:36:33Z")

</div>

Another option to speed up Flutter installation process is to include Flutter SDK in the Bitrise stacks. Beta and dev versions are available as archives. Linux version is ~300 MB, macOS one about 600 MB.

---

<div class="post-metadata">

**Author:** ![gedw99](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/gedw99/32/1212_2.png) [@gedw99](https://discuss.bitrise.io/u/gedw99)\
**Post date:** [April 28, 2018, 9:37am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/4 "2018-04-28T09:37:42Z")

</div>

This is just what I need. I was planning to do the same but just not time.

Is there a repo to show off how to do this ?

The caching idea will really help

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 30, 2018, 7:48pm UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/5 "2018-04-30T19:48:13Z")

</div>

> [@koral](#):
>
> Another option to speed up Flutter installation process is to include Flutter SDK in the Bitrise stacks.

How frequently the SDKs are updated? Also, does it matter which version is available, similar to e.g. the Android NDK?

---

<div class="post-metadata">

**Author:** ![koral](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/koral/32/357_2.png) [@koral](https://discuss.bitrise.io/u/koral)\
**Post date:** [May 1, 2018, 12:26am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/6 "2018-05-01T00:26:39Z")

</div>

> [@viktorbenei](#):
>
> How frequently the SDKs are updated?

> **[Flutter SDK archive](https://docs.flutter.dev/release/archive)**
>
> All current Flutter SDK releases: stable, beta, and master.

Dev versions are released every few days. Beta theoretically - every few weeks ([Flutter build release channels · flutter/flutter Wiki · GitHub](https://github.com/flutter/flutter/wiki/Flutter-build-release-channels)) but it does not match reality.

> [@viktorbenei](#):
>
> Also, does it matter which version is available, similar to e.g. the Android NDK?

No, in beta and dev channels you can download whichever version you want at anytime. Only in `master` channel there are no version numbers.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [May 1, 2018, 8:45am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/7 "2018-05-01T08:45:40Z")

</div>

> [@koral](#):
>
> Dev versions are released every few days. Beta theoretically - every few weeks

So pre-installing Dev versions wouldn’t help much, right? Even for Beta versions I’m not that sure, as we do the updates once a week, so if they release Betas frequently there’s a significant chance that it won’t be the right version for your project, right? I mean it will be either newer or older than the version you develop with but most likely not the exact same version, right?

---

<div class="post-metadata">

**Author:** ![koral](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/koral/32/357_2.png) [@koral](https://discuss.bitrise.io/u/koral)\
**Post date:** [May 2, 2018, 5:49pm UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/8 "2018-05-02T17:49:03Z")

</div>

Yep, it seems that we should wait for release version.

---

<div class="post-metadata">

**Author:** ![Matsue](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/matsue/32/2149_2.png) [@Matsue](https://discuss.bitrise.io/u/Matsue)\
**Post date:** [March 24, 2019, 9:43am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/9 "2019-03-24T09:43:55Z")

</div>

Flutter have stable version now, and stable versions will be released every quarter, so it is not every week. Let reconsider faster builds.  
Current “Flutter Install” step takes over 2 minutes for every builds, so it is better to add Flutter to stacks.

> We generally intend to roll the stable branch every quarter or so, probably with more fanfare than a regular beta roll.  
> [Release process · flutter/flutter Wiki · GitHub](https://github.com/flutter/flutter/wiki/Release-process)

---

<div class="post-metadata">

**Author:** ![fehersanyi-bitrise](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/fehersanyi-bitrise/32/1912_2.png) [@fehersanyi-bitrise](https://discuss.bitrise.io/u/fehersanyi-bitrise)\
**Post date:** [March 25, 2019, 9:42am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/10 "2019-03-25T09:42:19Z")

</div>

Hy, thanks for the heads up, I will talk to the developers in charge of this 🙃

UPDATE: We already have the card to add flutter to the hybrid stack, so it will be available soon 🙃

---

<div class="post-metadata">

**Author:** ![Matsue](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/matsue/32/2149_2.png) [@Matsue](https://discuss.bitrise.io/u/Matsue)\
**Post date:** [March 25, 2019, 12:09pm UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/11 "2019-03-25T12:09:08Z")

</div>

Thanks! I’m really looking forward to use the new stack! 🙃

---

<div class="post-metadata">

**Author:** ![dominik.roszkowski](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@dominik.roszkowski](https://discuss.bitrise.io/u/dominik.roszkowski)\
**Post date:** [May 11, 2019, 11:33am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/12 "2019-05-11T11:33:04Z")

</div>

Is there any update on this?

It still takes about 180 seconds to install Flutter on Hybrid stack and no other is available at the moment.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/d/da47e49974dee3cf4f81fa88866808607bd9c0a0.jpeg)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/0/00e43b149ee2cd24ddc33177feb16846a710e210.png)

Also, without setting version manually to v1.2.1 it takes more than 5-6 mins to install Flutter stable channel utilizing [this workaround](https://github.com/bitrise-steplib/bitrise-step-flutter-installer/issues/8#issuecomment-489199507).

 ![image](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/6/67678ed300fd22818b33dde355168b6b875c45df.png)

It means that it’s impossible to build even basic Flutter app on free plan.

If you add Firebase to the iOS app it takes almost 30 minutes to complete initial flutter build and then again 20 minutes to archive .ipa. So in other words it’s impossible to build iOS Flutter app with Firebase on Developer plan.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/0/08ca577d6e8ed8671dd01641fd602db0964ece8e.png)

This is very unpleasant experience as Bitrise is being promoted as mobile focused CI platform.

---

<div class="post-metadata">

**Author:** ![fehersanyi-bitrise](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/fehersanyi-bitrise/32/1912_2.png) [@fehersanyi-bitrise](https://discuss.bitrise.io/u/fehersanyi-bitrise)\
**Post date:** [May 14, 2019, 8:47am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/13 "2019-05-14T08:47:04Z")

</div>

I’m sad to hear you have these hardships, it is kind of hard to make it faster, because this is how flutter works, and it is out of our reach, we are currently trying to find a solution to cache flutter builds so that part could be faster.

---

<div class="post-metadata">

**Author:** ![Matsue](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/matsue/32/2149_2.png) [@Matsue](https://discuss.bitrise.io/u/Matsue)\
**Post date:** [July 14, 2019, 6:36am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/14 "2019-07-14T06:36:18Z")

</div>

Flutter is already installed on current macOS stacks. So we can reduce a time by skipping “Flutter Install” step on Workflow.  
Thanks for adding Flutter to macOS stacks!

---

<div class="post-metadata">

**Author:** ![oliver-polydelic](https://avatars.discourse-cdn.com/v4/letter/o/3d9bf3/32.png) [@oliver-polydelic](https://discuss.bitrise.io/u/oliver-polydelic)\
**Post date:** [October 21, 2019, 5:44pm UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/15 "2019-10-21T17:44:29Z")

</div>

Hey guys I see the Stack but it’s not been updated for a long time so it’s now outdated.

---

<div class="post-metadata">

**Author:** ![Matsue](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/matsue/32/2149_2.png) [@Matsue](https://discuss.bitrise.io/u/Matsue)\
**Post date:** [November 12, 2019, 11:31am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/16 "2019-11-12T11:31:28Z")

</div>

Hi, the stack is updated to 1.9.1+hotfix.6 now. We can send Pull Request to osx-box-bootstrap repository, if updates are needed.  
[https://github.com/bitrise-io/osx-box-bootstrap/pull/193](https://github.com/bitrise-io/osx-box-bootstrap/pull/193)

---

<div class="post-metadata">

**Author:** ![Manney91](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Manney91](https://discuss.bitrise.io/u/Manney91)\
**Post date:** [February 26, 2020, 5:37am UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/17 "2020-02-26T05:37:16Z")

</div>

Hey @viktorbenei i was wondering if you could take a look at my issues:

> [@Build aborts at running scripts from flutter deployment for iOS step due to timeout](http://discuss.bitrise.io/t/build-aborts-at-running-scripts-from-flutter-deployment-for-ios-step-due-to-timeout/12048/3):
>
> Hi, Support access has been enabled and here is the link to the project: link to app: [https://app.bitrise.io/app/c3c94d3b9847a408#/](https://app.bitrise.io/app/c3c94d3b9847a408#/)

I seem to have my flutter deployment running continuously but i do not know what the issues are, i was wondering if a second eyes could take a look at it.

---

<div class="post-metadata">

**Author:** ![realappie](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/realappie/32/3087_2.png) [@realappie](https://discuss.bitrise.io/u/realappie)\
**Post date:** [August 28, 2020, 5:43pm UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/18 "2020-08-28T17:43:57Z")

</div>

I’m having this exact issue, I am very curious if the build speed is quicker after caches are created. Sadly my builds aborts at 45 minutes and the bitrise cache push step is never reached, so I will never know. Its incredibly frustrating “flutter-build” step takes about **60 seconds** locally (macbook pro 16 inch) and 32 minutes on the build server. Thats 32 times slower 😅

Information regarding my project:

Bare bone project with a firebase integration, here are the dependencies I’m using.

cloud\_firestore: ^0.14.0+2  
firebase\_core: ^0.5.0  
sign\_in\_with\_apple: ^2.5.2  
firebase\_auth: ^0.18.0+1

“flutter-installer” takes ~ 2 minutes and downloads Flutter v1.17.1

Edit: This seems like a firebase specific issue, one with a solution outlined in the following github issue.

> <https://github.com/FirebaseExtended/flutterfire/issues/2751>
>
> Hey everyone 👋 
> 
> One of the key issues we wanted to look into providing a solu…tion for was https://github.com/FirebaseExtended/flutterfire/issues/349 - improving build times for Xcode when using Firestore.
> 
> I'm happy to say we now have something for you to try (please provide feedback) that should significantly improve your build times;
> 
> \*\*Mac mini (2018) 6 cores\*\*:
> 
> \`\`\`
> Before: ~ 240s
> After: ~ 45s
> \`\`\`
> 
> \*\*GitHub Action CI 2 cores\*\*:
> 
> \`\`\`
> Before: ~ 551s
> After: ~ 174s
> \`\`\`
> 
> \----
> 
> \### Why is it slow?
> 
> Currently the Firestore iOS SDK depends on some 500k lines of mostly C++ code (from dependencies such as gRPC), which when compiling as part of your Xcode build can take a long time - even more so in CI environments.
> 
> \### How can we speed it up?
> 
> The biggest win to improving build times would be to not have to compile all that C++ code. The way to do that would be to consume precompiled binaries, in the new \`XCFramework\` bundle type introduced to Xcode last year, luckily as part of the Firebase iOS SDK release process these bundles are generated and published in a zip containing all Firebase SDKs.
> 
> To help you consume these quicker with the least amount of changes to your codebase we've created \[invertase/firestore-ios-sdk-frameworks\](https://github.com/invertase/firestore-ios-sdk-frameworks) - a repository that provides a drop in replacement podspec for Firestore that consumes the precompiled binaries instead, without you needing to download 3gb of SDKs and manually extract out the Firestore SDKs from the rest of the SDKs in the zip.
> 
> \#### ⚡ Setup ⚡
> 
> To integrate, you just need to add 1 line to your \`ios/Podfile\` inside your Flutter project;
> 
> \`\`\`ruby
> pod 'FirebaseFirestore', :git =\> 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag =\> '7.4.0'
> \`\`\`
> 
> Add this line inside your \`target 'Runner' do\` block in your Podfile, e.g.:
> 
> \`\`\`ruby
> \# ...
> target 'Runner' do
> pod 'FirebaseFirestore', :git =\> 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag =\> '7.4.0'
> 
> \# ...
> end
> \`\`\`
> 
> No changes to the FlutterFire packages were required. See #4698 for a full example of integrating with automatic versioning based on what \`firebase\_core\` uses.
> 
> \### Why not ship the binaries with the pub packages?
> 
> This would add ~200mb to every release. Whereas via a custom pod this is only ever downloaded once on your machine per Firebase iOS SDK version.
> 
> \----
> 
> For more information on the \`pod\` and versioning please see the \[invertase/firestore-ios-sdk-frameworks\](https://github.com/invertase/firestore-ios-sdk-frameworks) repository.
> 
> \----
> 
> \*\*⚠️ Note:\*\* if you were previously caching iOS builds on CI you may now find that when using precompiled binaries that caching is no longer required and it may actually slow down your build times by several minutes. See this comment below for more; https://github.com/FirebaseExtended/flutterfire/issues/2751#issuecomment-643190500
> 
> \----
> 
> ✨ \*\*Please let me know if this has helped you, and I would love to see some before and after timings if you feel like sharing\*\* ✨

I can confirm my build times have been greatly reduced after following the instructions in that github issue

Before

 ![48](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/0/04240336d2dc7a4315a4eeaf6c9628d3054b7de9.png)

After

 ![download](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/9/97a27127068c63c1e4f33c9faf353b4e2d5671f0.png)

---

<div class="post-metadata">

**Author:** ![danielgomezrico](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/danielgomezrico/32/2290_2.png) [@danielgomezrico](https://discuss.bitrise.io/u/danielgomezrico)\
**Post date:** [February 17, 2021, 4:41pm UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/19 "2021-02-17T16:41:33Z")

</div>

@viktorbenei check:

> **[Hotfixes to the Stable Channel · flutter/flutter Wiki](https://github.com/flutter/flutter/wiki/Hotfixes-to-the-Stable-Channel)**
>
> Flutter makes it easy and fast to build beautiful apps for mobile and beyond. - Hotfixes to the Stable Channel · flutter/flutter Wiki

They do some hotfix releases montly or so, but for mayor versions they take more than that.

I believe that it will be really valuable to have that in bitrise, specialy on flutter because we build iOS and android and removing time in the middle will help the CI process a lot.

---

<div class="post-metadata">

**Author:** ![cathy.harmon](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/cathy.harmon/32/2674_2.png) [@cathy.harmon](https://discuss.bitrise.io/u/cathy.harmon)\
**Post date:** [March 5, 2021, 6:41pm UTC](https://discuss.bitrise.io/t/making-flutter-builds-faster/3976/20 "2021-03-05T18:41:39Z")

</div>

Hello,

Generally we do not have hot fixes or release candidates install on the stack in order to provide a stable environment for the majority of users. If you do need a hotfix release you can easily install it during your build.

Thanks
