143

I'm new to Flutter, was just wondering if it's possible.

I've tried building the demo code using intellij with given instruction (https://flutter.io/setup/). It runs well on android device, but can't find the option to compile and run on my iOS device.

Payam Khaninejad
  • 7,692
  • 6
  • 45
  • 55
YYY
  • 1,659
  • 2
  • 12
  • 11
  • 4
    In order to compile/run for iOS you'll need a Mac. This requirement has always been the case since the first iPhone. – Morrison Chang Oct 30 '17 at 02:25
  • @MorrisonChang is correct. You probably cannot run the iOS version from a Windows machine. – dasfima Oct 31 '17 at 13:09
  • With NativeScript it is possible to build the iOS version in the cloud (https://docs.nativescript.org/sidekick/getting-started/build). With Xamarin you can use the Xamarin Live Player app to test your code on an iOS device. I hope Google will also come up with something similar in the future. – ndreisg Aug 29 '18 at 06:44
  • unfortunately flutter not capable for it. flutter looks good but with adobe air you are able to build and run application on ios device via usb without needing a macos. adobe has it ages ago ) Google should also able to make that support. – Fuad All Apr 14 '19 at 09:46

8 Answers8

115

You can do your main development on Linux or Windows with Android Studio or Visual Studio Code. Then use git to move the code to macOS to test it with Xcode on an iOS simulator/device and deploy it to the App Store.

You could do all development on macOS but you can't do all development on Linux or Windows. I'm not too pleased with Apple for making overpriced machines and then forcing us to buy them. Since I can't afford a fast Apple computer, I am planning to do most of my development on Linux and then just do testing and deployment on my painfully slow Mac Mini.

Update

It seems like there are more possibilities now. Read the following articles:

Personally, I ended up buying a MacBook Pro for way too much money. I have to admit that it is convenient, but I have done very little up to this point that really required it. I'm doing all of my learning and development in Android Studio and usually use the Android emulator. Every now and then I fire up the iOS simulator, but I haven't been required to.

My advice is to keep using your current system (Windows or Linux) for as long as you are learning and even while you are developing your first Flutter apps. Eventually you may appreciate the convenience of having the iOS Simulator and Xcode on the same machine, but there is certainly no rush.

AmaanK
  • 1,032
  • 5
  • 25
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
  • 11
    There are also some hosted virtual macs available. I am using a cloud hosted one and it works great for compiling. Another alternative would be a virtual machine on your computer. – Bostrot Jul 05 '18 at 15:44
  • 1
    @Bostrot Any link(s) for hosted macs would be helpful. – gegobyte Apr 23 '19 at 12:38
  • 1
    @Chinmay Sarupria I personally only know macincloud but a google search will get you more. – Bostrot Apr 23 '19 at 17:07
  • 1
    can anyone recommend a tutorial on how to set up virtual machine with mac OS on Windows? – Kirill Karmazin Jan 22 '20 at 18:15
39

You could do that with a Mac (or Hackintosh, or VM), but since we don’t have access to a macOS machine we can use one remotely via Codemagic or Travis CI — completely free! (as long as your project is on a GitHub, Bitbucket or GitLab repository).

First, create an account or sign in to codemagic.io.

Then, click the settings (gear) icon next to your app. Scroll down and click on “Build”. Make sure Mode is set to Debug, and select iOS under Build for platforms.

After that, build the app (Start your first build).

Codemagic will send you an .app file via email. Rename it so that it ends with .zip. Extract it, and you’ll get a folder called Runner.app. Create a folder called Payload and place Runner.app there. Finally , compress the folder called Payload — this will be your IPA file (you may rename it to .ipa).

Alternative: Building the app with Travis CI You’ll need to create an account on Travis CI and let it access your GitHub account.

Then, create .travis.yml on the root of your project with the following contents:

 os: osx 
    language: generic 
    before_script: 
     - brew update 
     - brew install --HEAD usbmuxd 
     - brew unlink usbmuxd 
     - brew link usbmuxd 
     - brew install --HEAD libimobiledevice 
     - brew install ideviceinstaller 
     - brew install ios-deploy 
     - git clone https://github.com/flutter/flutter.git -b beta --depth 1 
    script: 
     - flutter/bin/flutter build ios --debug --no-codesign
    cache: 
      directories: 
      - $HOME/.pub-cache
    before_deploy: 
      - pushd build/ios/iphoneos 
      - mkdir Payload 
      - cd Payload 
      - ln -s ../Runner.app 
      - cd .. 
      - zip -r app.ipa Payload 
      - popd

More info

Payam Khaninejad
  • 7,692
  • 6
  • 45
  • 55
  • 2
    yeah, but I would like to run it on iOS and take a look at the new version at least once before rolling out. You can't just test on Android, then build for iOS prod – Kirill Karmazin Jan 22 '20 at 16:56
  • @KirillKarmazin I recommend you to write tests based on OS and use Fastlane or Codemagic CI/CD before build and release. In other scenarios that you mentioned, you had to build Flutter in Mac then your target release first would be iOS than Android. – Payam Khaninejad Jan 23 '20 at 05:18
  • Does my Bitbucket repository must be public in order to be accepted for free builds on CodeMagic? – Ulysses Alves Aug 25 '20 at 11:20
  • 1
    @UlyssesAlves no, it doesn't require to be public – Payam Khaninejad Aug 25 '20 at 18:36
  • 1
    free but limited by the number of hours, compiling using macos VM is also expensive on codemagic / github actions – Ruelos Joel Jun 20 '22 at 14:46
12

I suggest you use a virtual machine to do your thing.. I had a Mojave MacOS installed on my Windows 10 and I had things running smoothly!

A Mojave image can be got from https://getintopc.com/softwares/operating-systems/mac-os-mojave-10-14-1-vmware-image-free-download/

I found this useful as I had some things that I wanted out of the Mac world while I had a dell latitude.

emanuel sanga
  • 815
  • 13
  • 17
  • were you able to connect your iPhone device to your mac os on virtual machine? – Kirill Karmazin Jan 28 '20 at 21:25
  • I didnt test that out.. but i dont think if it is possible... a simulator might do the work – emanuel sanga Mar 03 '20 at 15:08
  • 4
    @emanuel_sanga I can confirm that it is possible. I did it without any problems. I've set up a VMware Workstation virtual machine on my Windows 8.1 and run a Mojave image there. Then you have to install XCode and do all the Apple ID related sign-in steps. Then you can plug in your iPhone (signed in with your Apple ID) and they work fine. By the way - real physical device seems to be the only way to test notifications since they don't work properly on simulators (for example if you are using Firebase) – Kirill Karmazin Mar 04 '20 at 16:42
  • Note that it's against MacOS terms of use to install on non-apple hardware. – Inrego Jun 24 '21 at 06:54
  • Yes yes @Inrego. But from quora, seems to have effect when done for mass & commercial production. Here's the link https://www.quora.com/Is-it-illegal-to-install-OS-X-on-non-Apple-hardware-aka-Hackintosh. I would be glad if you also share your resources for others to see too – emanuel sanga Jun 24 '21 at 07:43
9

3 years later after the this question was asked:

https://aws.amazon.com/about-aws/whats-new/2020/11/announcing-amazon-ec2-mac-instances-for-macos/

AWS now supports one demand macOS as an EC2 instance. Haven't tested this out myself as this was just released, but hopefully, this can replace the painful little mac mini that's working extra hard without work-life balance XD

elderg
  • 91
  • 1
  • 1
6

Apple has made compiling of iOS applications exclusively avaible to macOS.

You can read through this answer and thread to look into workarounds for getting it to work on Windows.

Basically there is no other way for Flutter, but Xamarin and NativeScript provide support for it.

creativecreatorormaybenot
  • 114,516
  • 58
  • 291
  • 402
4

you can read this article

it uses some tools and CodeMagic to build Flutter app for Ios.

  1. put your app on GitHub (public) and give access to codemagic
  2. then you should build your app using code magic for IOS.
  3. then you should use Cydia Impactor for signing the file that CodeMagic has sent to you
  4. prepare your windows machine by installing libimobiledevice , ideviceinstaller,which.
  5. Modify Flutter code to not looking for Xcode
  6. Running and debugging

I have used this method it works fine you can hot reload and debug your app the downside is you have to enter apple id password in Cydia Impactor which for sure you should use a second apple id and after apple provisioning profile expiring you should sign your code with Cydia Impactor again. but it's so much cheaper than by a Mac or rent one.

Pouya Samie
  • 3,718
  • 1
  • 21
  • 34
  • Unfortunately, currently, this method doesn't work. There are some records on the Cydia Impactor forum which haven't been answered since December 2019 regarding 71 error message that does not let install the app. Also, they ask for your iCloud login and password. – kovalyovi Feb 29 '20 at 04:58
2

On Windows, you can also use a python utility tool named Appollo to :

  • Configure XCode
  • Test your app on the iOS simulator
  • Build an IPA for on device testing
  • Sign and publish your app

Here is a quick demo of Appollo for building and publishing an app : https://www.youtube.com/watch?v=D9NYNmXFphE

First you need to install the appollo cli tool through your console.

pip install appollo

Secondly, set up Appollo with your Apple Developer Account : https://appollo.readthedocs.io/en/master/tutorial/2_configure_app_store_connect.html

Thirdly, in the case you want to build and publish your app for testing and/or for publication, you can run this in your terminal :

appollo build start

And that's all there is to it.

Maxime Deuse
  • 313
  • 11
  • 13
2

Now we have Xcode Cloud https://developer.apple.com/xcode-cloud/ so hopefully we will see some decoupling from iOS. If we would have iOS simulator on Windows that would put the crown on Windows iOS development.

giorgio79
  • 3,787
  • 9
  • 53
  • 85