Flutter Desktop - generate .exe from Mac
Solution 1
The flutter
tool has no support for cross-compiling desktop targets, so there is no straightforward way to do what you want.
If you want to do it manually you would need to (in addition to setting up a cross-compilation toolchain for building Windows applications from macOS in general) either:
- manually recreate the pre-build steps that are normally done automatically by
flutter
(download the correct Flutter DLL and place it in the expected location, do the same with the C++ wrapper if you are using it, create the.props
file with correct values, etc.), then build the.sln
directly, or - locally modify
flutter_tool
so that it doesn't do a host platform check for the Windows steps, and rewrite the way it locatesmsbuild
to work on macOS.
Solution 2
The documentation says:
No cross-compilation support (issue 28617)
The compiler supports creating machine code only for the operating system it’s running on. You need to run the compiler three times — on macOS, Windows, and Linux — to create executables for all three operating systems. A workaround is to use a CI (continuous integration) provider that supports all three operating systems.
Patryk Jabłoński
By day: Senior Software Engineer. In free time: Amateur Boxer and Muay Thai fighter
Updated on December 12, 2022Comments
-
Patryk Jabłoński over 1 year
I have started my journey with Flutter desktop. Till now everything was working fine. I was developing an application and it was building for the macOS like a charm. Now I would like to create the executable file for windows (.exe). Is it possible to generate one from the macOS? If so how can I achieve something like this?
EDIT:
To be able to build an executable version of the app we need to do that from the operating system that we want our app to be run on. In my case, I am using Mac on a daily basis, so I had to create the virtual machine to build the .exe for windows
-
Patryk Jabłoński almost 5 yearsOk, so if I have to do something quickly it would be better to just build the app on the machine with windows.
-
Patryk Jabłoński over 3 yearsYeah. That is right. I had to run build on a machine with the destination operating system