Flutter iOS physical device error: Command PhaseScriptExecution failed with a nonzero exit code

Issue

I have created a new flutter project on Android studio. When I try to run it on emulator it works fine, but when I run it on my iphone it gives this error:

Command PhaseScriptExecution failed with a nonzero exit code

When I check the "For install builds only" checkbox in the Target>Build Phases>Run Scripts, it gives another error

'Flutter/Flutter.h' file not found

I have tried deleting and recreating the ios directory, but no luck.

Below is flutter doctor output

[✓] Flutter (Channel stable, 2.0.5, on macOS 11.2 20D64 darwin-x64, locale en-PK)
• Flutter version 2.0.5 at /Users/naveediqbal/Development/flutter
• Framework revision adc687823a (6 days ago), 2021-04-16 09:40:20 -0700
• Engine revision b09f014e96
• Dart version 2.12.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/naveediqbal/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.1

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
  🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
  🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.53.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
  🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
• Naveed’s iPhone (mobile)   • 00008030-000D14561AA3802E            • ios            • iOS 14.4
• iPhone 12 Pro Max (mobile) • 07F0FF94-7241-4A89-AA5E-A33CB40F1687 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
• Chrome (web)               • chrome                               • web-javascript • Google Chrome 90.0.4430.85

• No issues found!

Solution

First of all, you need to uncheck "For install builds only" back. Then all you need to do is make sure that your MacBook and your iPhone are on the same apple id.

Additional check:
Furthermore, just make sure you also trust your developer account. For that Go to your Iphone Settings -> General -> Device Management and "trust" yourself as developer.

Now try running on your physical device (iPhone)

Answered By – Taha Asif

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.