Search code examples
flutterdartgithub-actionscicd

Set Target Platform with Flutter Build


I'm setting up a CI pipeline for a Flutter app using Github Workflows.

For this, I want to build for each of the following platforms:

  • Windows x64
  • MacOS x64
  • MacOS arm64
  • Linux x64
  • Android arm64

So, what I can't seem to do is work out how to determine whether to build for arm64 or x64 when running flutter build macos there doesn't seem to be any sort of --target-platform flag that I can use.

Surely this must be possible?


Solution

  • Flutter builds universal binaries when targeting macOS, so you can just build once and the output will run on both arm64 and x86_64 Mac machines.

    If you still want separate builds for each architecture, you can specify which architecture to build for with the FLUTTER_XCODE_ARCHS environment variable. Set it to either x86_64 or arm64 depending on which architecture you want to build for.