Build Flutter app in release mode for iOS

moonvader picture moonvader · Mar 28, 2018 · Viewed 25k times · Source

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?

Answer

moonvader picture moonvader · Mar 28, 2018

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.