46

I have Android Studio with Flutter plugin installed. Flutter SDK is also installed on my Mac through Android Studio and I know path to it.

I want to run my app in release mode on real iOS device. Not only to hide "slow mode" banner that can be done using this code as I know

new MaterialApp(
  debugShowCheckedModeBanner: false,
  ...

but also to check how my app works.

I found this instructions https://flutter.io/ios-release/ but still can't build app in release mode.

Each time I try to run flutter command in terminal, I got:

flutter: command not found

I think that it is because I had installed Flutter SDK from Android Studio and I should update some pathes. So what are my steps to build flutter app in release mode using Xcode?

5
  • You need to add flutter/bin to your path Mar 28, 2018 at 9:25
  • so I open my terminal, where should I go with cd command? and what should I do next?
    – moonvader
    Mar 28, 2018 at 9:27
  • Follow the instructions here Mar 28, 2018 at 9:46
  • Sorry, that doesn't helping.
    – moonvader
    Mar 28, 2018 at 9:47
  • It should. There's a problem with your install. Mar 28, 2018 at 9:51

7 Answers 7

67

Even after running flutter build ios, Xcode always ran the Debug version (slow mode).

To solve this, I had to change the Build Configuration of the Run schema:

  1. Click on Runner, and Edit scheme

enter image description here

  1. Select Release for the Build Configuration of the Run schema

enter image description here

Hoping this is helpful.

6
  • 1
    Very useful - this is the first time I am seeing this. So far for all the docs and reading I have been looking at on running a Flutter iOS build, I have not run across this important detail until your post. Big Thanks
    – Gene Bo
    Jun 8, 2020 at 4:13
  • 4
    By default flutter build ios use --debug mode. In order to make it run in release, you need to add --release explicitly. I.e flutter build ios --release
    – nahung89
    Jun 15, 2020 at 10:01
  • 8
    No, flutter build ios uses --release mode by default.
    – Lucas
    Jun 16, 2020 at 12:58
  • Very helpful, didn't see this either!! They should put it in the release docs, given that flutter build iOS creates a release build by default and Xcode is not very revealing on this, it's easy to get wrong on this one.
    – JJuice
    Dec 28, 2020 at 21:29
  • 1
    Lately my laptop will not recognise that my iOS devices are connected except via Xcode - so I have to build/run via Xcode - so happy to find that this flag can be set this way - thank you ! Also - while it is right there in the answer, I somehow missed the "Set to Run schema" on my first try of this - make sure you do that step ! :)
    – kris
    Feb 22, 2021 at 1:18
34

Building steps

If you have problems using flutter command in terminal because it is not found - read Configuring steps below.

Step 1

Open terminal, run command

cd /Users/John/myFlutterApp/

Run

flutter build ios

Open Xcode and run .xcworkspace file in iOS folder. It should now work smoothly and Slow mode banner should be gone.

Configuring steps

Step 1

Locate folder where flutter is installed on your mac. If it was installed using Android Studio. Just open Android Studio create new flutter project and you will see Flutter SDK path. For example let it be /Users/John/flutter/

Step 2

open terminal on your Mac and run

cd /Users/John/

As you can see we are now one level up from SDK path

Step 3

run

export PATH=`pwd`/flutter/bin:$PATH

If you now run flutter in terminal you should see list of available params. So you can run

flutter doctor

To check is everything is fine with installation. Now flutter command only works for this terminal session. And if you close it and later open it again and run fuller command - you will get error that this command is unknown. So you want to save flutter command to be available even after terminal was closed.

Step 4

run

open ~/.bash_profile

you will see text editor where you need to paste

export PATH=/Users/John/flutter/bin:$PATH

save file. If you close terminal now and open it again - you should be able to run flutter command.

3
  • 1
    Helpful answer! I didn't know that you have to run flutter build ios from command line to build in release mode.
    – Alexey
    Jun 24, 2018 at 11:17
  • 1
    otherwise app will run much slower
    – moonvader
    Jun 24, 2018 at 12:12
  • 1
    To publish the app on App Store specify development team or enable automatic sign-in in Xcode , then run flutter build ios --release and it will make release build. Sep 25, 2019 at 7:00
30

You can Run your application in Release Mode easily in your terminal using :

flutter run --release

And it will switch to Release Mode .

But if you don't want to run your app , just want to build your apk or ipa ,
Use :

 flutter build --release

You can specify to build for ios by using flutter build ios

1
  • but if you disable the developer mode from your iPhone/ iPad application will not run. Nov 2, 2022 at 6:17
21

Follow these 3 steps:

  1. Open your Flutter project in Xcode.
  2. Top Bar Product > Scheme > Edit Scheme
  3. Build Configuration - Select Release

Note: Release type flutter app is valid for 7 days on iOS devices.

enter image description here

enter image description here

18

You could do it from Android Studio directly as well.

> Run
> Flutter Run 'main.dart' in Release Mode

enter image description here

7

I just wanted to build the ios .ipa file for the testing purpose without any hustle, follow are the step I took, and hopefully, they will be helpful.

  1. In the terminal run this command.

    flutter build ios --release --no-codesign

  2. After that go to the folder where the output is stored.

build/ios/iphoneos

  1. After that you will have to create a new directory/folder in the iphoneos folder called "Payload".

  2. After that move the output file "Runner.app" (name can be different) to the "Payload" folder.

  3. Then compress the "Payload" folder and rename to "YouAppName.ipa". (make sure to change the extension)

And it's done.

The solution will help you get .ipa file without signing.

-1

If you want to use only Android Studio to deploy your app in release mode, you can also add the --release flag to your Run/Debug configuration manually.

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.