47

My Flutter Project won't run on the ios simulator and is throwing this error:

Launching lib/main.dart on iPhone Xʀ in debug mode...

Running Xcode build...

Xcode build done. 7.6s

Failed to build iOS app

Error output from Xcode build:

** BUILD FAILED **

Xcode's output:

=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===

/bin/sh: /Users/pinercode/AndroidStudioProjects/bmi-calculator-flutter/packages/flutter_tools/bin/xcode_backend.sh: No such file or directory

Could not build the application for the simulator.

Error launching application on iPhone Xʀ.

The xcode error was also as follows:

/bin/sh: /Users/pinercode/AndroidStudioProjects/bmi-calculator-flutter/packages/flutter_tools/bin/xcode_backend.sh: No such file or directory

I've already tried running flutter doctor and there were no errors. I also tried re-rooting my xcode 'FLUTTER_ROOT' and 'FLUTTER_APPLICATION_PATH' in build settings, which did not work.

Community
  • 1
  • 1
James 666
  • 1,560
  • 1
  • 15
  • 27

12 Answers12

62

after a lot of messing around, I set these two settings and the build ran on to my physical device.

  • Goto Xcode,

  • click on Runner

  • select Project (top one)

  • go to Info tab

  • change configurations for debug

  • top Runner (green icon) to Generated

  • Bottom Runner (red circles) Pods-Runner-debug

James Bucanek
  • 3,299
  • 3
  • 14
  • 30
Chris
  • 621
  • 5
  • 3
55

use this settings:

  1. Open Xcode - Click on Runner(Top one)
  2. Select the Runner from "PROJECT" Not from "TARGETS"
  3. Select configuration
  4. And update all the modes as this photo

enter image description here

Majid Hajibaba
  • 3,105
  • 6
  • 23
  • 55
Yahya
  • 551
  • 4
  • 4
47

Basically what happens is that one of the project's 'Build Phases' is running a script:

/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build

Now in order to find xcode_backend.sh the FLUTTER_ROOT variable needs to be defined. It is defined in a file called Flutter/Generated.xcconfig, which is generated when you run flutter pub get or flutter build.

The build configuration files Debug.xcconfig and Release.xcconfig (in the same Flutter folder) include Generated.xcconfig. Now the only thing left is to ensure that for each of the project configurations these build configuration files are properly set (in XCode under Project > Info > Configuration).

Boken
  • 4,825
  • 10
  • 32
  • 42
Sebastian Engel
  • 3,500
  • 32
  • 30
  • I am not quite clear, does this mean that mean we just want to ensure that a configuration file is set for each target? https://a.cl.ly/YEuk4Qjq – satchel Jul 14 '22 at 19:40
22

Open Xcode
Click on Runner(Top one)
Select the Runner from "PROJECT" Not from "TARGETS"
Select configuration
And update all the modes for ex: In debug select "debug" configuration set

enter image description here

Sanju Bhatt
  • 944
  • 10
  • 7
12

By Setting FLUTTER_ROOT as the Flutter sdk path solved this issue for me.

enter image description here

Al Walid Ashik
  • 1,545
  • 20
  • 32
8

Setting runner to Generated in project->Info Configurations seemed to fix it. I can build in xcode now.

pluto puppy
  • 231
  • 4
  • 6
  • This fixed the problem and it build successfully. However, I had to update my Xcode version to the latest to support the latest version on my iPhone. – Hanny Jul 12 '20 at 17:27
  • That's the fix for me. I set project runner to generated and target runner to None. – Abbas Jul 09 '21 at 05:35
2

The simple solution was to call

flutter clean

flutter run

and then run the app from Xcode.

Sohaib Aslam
  • 1,245
  • 17
  • 27
1

If changing the configuration as suggested above doesn't fix things

In your Build Phase scripts / Xcode Project change

$FLUTTER_ROOT/packages/flutter_tools/...

to

${FLUTTER_ROOT}/packages/flutter_tools/...

Did the trick for me after the upgrade to the new version of flutter broke the Build.

abhideep
  • 125
  • 6
1

i have this intermittently while setting up flavors havent got an answer on fixing it but the best explanation of the trail is here https://github.com/flutter/flutter/issues/49495

martinseal1987
  • 1,862
  • 8
  • 44
  • 77
1

What helped me was going under PROJECT -> Info -> Configurations

setting the following:

Debug:
    Runner - None
    fRunner - Debug

Release:
    Runner - None
    fRunner - Release 

Profile:
    Runner - None
    fRunner - Generated
Marcel Hofgesang
  • 951
  • 1
  • 15
  • 36
1

What worked for me was:

  1. Removing my project ios folder.

(Save it elsewhere, as you will probably want to keep your Info.plist file and Podfile.)

  1. Run flutter create . to build a new ios folder.

  2. Replace new Info.plist and Podfile with originals.

(If you have firebase in your app as I did you likely will have to go into xcode and right-click on runner, add files to runner, and add your GoogleService-Info.plist)

  1. flutter clean , flutter run
greenzebra
  • 412
  • 1
  • 5
  • 18
0

I tried all solutions but no one worked :( , I think there is a something missing in the flutter folder so the fast simple solution is ;)

  1. delete flutter folder
  2. Download the stable branch straight from GitHub instead of using an archive (url: https://docs.flutter.dev/get-started/install/macos)

git clone https://github.com/flutter/flutter.git -b stable

  1. Verify that the flutter/bin directory is in your PATH by running echo $PATH

  2. flutter upgrade flutter config enable-ios flutter config enable-android flutter doctor --android-licenses flutter doctor -v

  3. cd path/your_project_name

flutter run ios -t lib/main.dart

i.AGUIR
  • 599
  • 4
  • 6