80

I am trying to add flutter to the existing app. So before doing on the production app I tried with brand new Xcode 10 Single View Application. I followed the tutorial here on https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps and got stuck after adding the run script in the build phase of my target. It's giving the error:

Error:

iphoneos/AFEiOS.build
    export TEMP_ROOT=/Users/dhavalkansara/Library/Developer/Xcode/DerivedData/AFEiOS-gctxucyuhlhesnfkbuxfswkozboo/Build/Intermediates.noindex
    export TOOLCHAINS=com.apple.dt.toolchain.XcodeDefault
    export TOOLCHAIN_DIR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
    export TREAT_MISSING_BASELINES_AS_TEST_FAILURES=NO
    export TeamIdentifierPrefix=RQ9BPQCP49.
    export UID=501
    export UNLOCALIZED_RESOURCES_FOLDER_PATH=AFEiOS.app
    export UNSTRIPPED_PRODUCT=NO
    export USER=dhavalkansara
    export USER_APPS_DIR=/Users/dhavalkansara/Applications
    export USER_LIBRARY_DIR=/Users/dhavalkansara/Library
    export USE_DYNAMIC_NO_PIC=YES
    export USE_HEADERMAP=YES
    export USE_HEADER_SYMLINKS=NO
    export VALIDATE_PRODUCT=NO
    export VALID_ARCHS="arm64 arm64e armv7 armv7s"
    export VERBOSE_PBXCP=NO
    export VERSIONPLIST_PATH=AFEiOS.app/version.plist
    export VERSION_INFO_BUILDER=dhavalkansara
    export VERSION_INFO_FILE=AFEiOS_vers.c
    export VERSION_INFO_STRING=""@(#)PROGRAM:AFEiOS  PROJECT:AFEiOS-""
    export WRAPPER_EXTENSION=app
    export WRAPPER_NAME=AFEiOS.app
    export WRAPPER_SUFFIX=.app
    export WRAP_ASSET_PACKS_IN_SEPARATE_DIRECTORIES=NO
    export XCODE_APP_SUPPORT_DIR=/Applications/Xcode.app/Contents/Developer/Library/Xcode
    export XCODE_PRODUCT_BUILD_VERSION=10E1001
    export XCODE_VERSION_ACTUAL=1020
    export XCODE_VERSION_MAJOR=1000
    export XCODE_VERSION_MINOR=1020
    export XPCSERVICES_FOLDER_PATH=AFEiOS.app/XPCServices
    export YACC=yacc
    export arch=undefined_arch
    export variant=normal
    /bin/sh -c /Users/dhavalkansara/Library/Developer/Xcode/DerivedData/AFEiOS-gctxucyuhlhesnfkbuxfswkozboo/Build/Intermediates.noindex/AFEiOS.build/Debug-iphoneos/AFEiOS.build/Script-19DAA30A22C0FB0100A039E2.sh

The path lib/main.dart does not exist
The path  does not exist
Command PhaseScriptExecution failed with a nonzero exit code

I have tried below things.

My pod file:

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

target 'AFEiOS' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for AFEiOS

  target 'AFEiOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'AFEiOSUITests' do
    inherit! :search_paths
    # Pods for testing
  end

    flutter_application_path = '/Users/dhavalkansara/FlutterToNative/AFE_flutter/'
    eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)


end
  • Already added FLUTTER_ROOT in my project.

Please help me out with this issue.

35 Answers 35

78

This work for me Thanks Alexander Lozano, I upload image for Xcode Version 12.0.1

Xcode Version 12.0.1

Sign up to request clarification or add additional context in comments.

9 Comments

I GOT NEW ERROR: Undefined symbols for architecture armv7: "_OBJC_CLASS_$_FlutterAppDelegate", referenced from: type metadata for Runner.AppDelegate in AppDelegate.o "_OBJC_METACLASS_$_FlutterAppDelegate", referenced from: _OBJC_METACLASS_$__TtC6Runner11AppDelegate in AppDelegate.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) Undefined symbols for architecture arm64: "_OBJC_CLASS_$_FlutterAppDelegate", referenced from:
This helped me on my Mac with M1 chip, my friend didnt need this on Intel chip on the same project. Can this change be dangerous?
I have 1 error message, I check the box, now I have 3 errors. Thanks
People stop doing this. I see this is an accepted answer. but please turn it back off. Check the Comment by jmagman on flutter. github.com/flutter/flutter/issues/99387#issuecomment-1105467295. this is a terrible advice and don't follow it. Changing this setting will cause the issue Flutter.h not found.
This is a bad solution that can lead to other problems. For me updating flutter has worked multiple times when I've had this error - flutter upgrade
|
35

this works for me: xcode 11.3.1

xcode ->targets->runner

in build phases: run script and thin binary, select: run script only when installing

8 Comments

OMG I have been 2 days trying to resolve this Thanks so much
Is there a downside of doing this?
Yes, you'll still be using Flutter. :\ All kidding aside, I've been looking for that very answer, and no one seems to know. Meanwhile, this didn't work for me, and my quest continues. :(
i dont have that option, just "for install builds only" and "based on dependency analysis", help!
xcode 13.2.1,this work for me,thanks!
|
10

Make sure configuration is set correctly to Debug, mine was set to "none"

enter image description here

1 Comment

two days. 48 hours, thats how much time i spent trying to figure out what was wrong. thank you kind sir. Thank you so much
7

Anyone facing problem when building or archiving for 1st time on xcode

How I resolved this issue:

  1. clean flutter project with flutter clean
  2. build project with flutter build ios. This will sign app to the appstore
  3. build/archive app on xcode

Comments

6

I was having the issue for 2 days.

My failure was slightly different:

Failed to package /path/to/my/app.
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in parallel

I was on Flutter 2.5.1, I tried all of the suggestions found here (amongst others I googled). I wish I knew the answer or understood why, but a simple

`flutter upgrade` 

Worked for me (I ended up with 2.5.3)

Comments

4

This worked for me:
1) Add this to your podfile:

flutter_application_path = '/Users/dhavalkansara/FlutterToNative/AFE_flutter/'
    eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)

    install_all_flutter_pods(flutter_application_path)

PS. You may also need to do that for each target, i.e

target 'AFEiOSTests' do
    inherit! :search_paths
    install_all_flutter_pods(flutter_application_path)
    # Pods for testing
  end

  target 'AFEiOSUITests' do
    inherit! :search_paths
    install_all_flutter_pods(flutter_application_path)
    # Pods for testing
  end

2) Run pod install

Comments

3

If you dig deep and try and find out what is causing this error - it will help you to go to the right direction. For me the reason for this error was "

"/packages/flutter_tools/bin/xcode_backend.sh: No such file or directory"

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.

Goto Project -> Runner -> Info -> Configurations

Debug Runner -> Generated (under Runner) Runner -> Pods-Runner.debug

Release Runner -> Generated (under Runner) Runner -> Pods-Runner.release

Profile Runner -> Generated (under Runner) Runner -> Pods-Runner.profile

At the end all the 3 will have 2 configurations set.

Best of luck :)

Comments

2

By doing flutter clean. Xcode builds clean.(Key: command+shift+k).

xcode ->targets->runner

in build phases: run script and thin binary, unselect: run script only when installing

then run flutter run in the terminal of the project resolve the issue for me.

2 Comments

I use Xcode 12.5.1, Flutter 2. This solution works for me. Thanks a lot
do NOT do this, per github.com/flutter/flutter/issues/99387#issuecomment-1081238267, since "you're shutting off all the Flutter tooling that builds your dart app."
2

Somewhat related to other questions, such as this. For me this started happening after some update in my Mac. The solution included a flutter clean + flutter pub get and restarting both the device (iPhone) and computer (Mac) - restarting the Mac made all the difference. Other answers may suggest to mark the "For install builds only" option on Xcode - that actually broke things for me, build started complaining about not finding Flutter.h. So yeah, restarting things may solve your problem. Perhaps throw in a flutter upgrade as well.

1 Comment

Im on Xcode 15. This solution of rebooting iphone and mac worked for me. Doing just flutter clean, pub get, xcode clean etc didn't work. I found that this issue can happen if u quit the flutter run (i.e. CTRL+C) command
2

this happen because some packages not updated

in Ios folder

  1. delete pods folder
  2. delete podfile.lock
  3. in podfile change version ( platform :ios, '11.0') '11' or higher
  4. flutter pub upgrade --major-versions (in project terminal)
  5. pod install (in ios terminal)
  6. flutter run

Comments

2

I tried everything from flutter clean to pod deintegrate to restarting to changing to "for install builds only". None solved my problem. This happened every time I made large changes to an auto-generated API. Deleting the pushing everything, deleting the folder, and re-cloning worked for me, but it was of course none ideal.

Instead of taking a solution wholesale here, you should run flutter run --verbose and trace the source of the error. In my case, I traced Member not found: 'FirebaseAppPlatform.verifyExtends'. to which this solution worked.

With a widely attributable error like this, always assess the risks of even more widely attributable solutions. Some of the solutions are quite dangerous.

1 Comment

flutter run --flavor dev --verbose does indeed help greatly in identifying the specific error likely related to the cause of the nonzero-exit error.
2

for flutter developers, I am also facing this problem and after doing RnD i am able to solve it as follow:

find frameworks.sh files to add the -f flag to the call to readlink.

source="$(readlink "${source}")"

replace with

source="$(readlink -f "${source}")"

here is the directory to find it:

Pods --> Target support files --> Pods-(Project_Name) --> frameworks.sh(Pods-Runner-frameworks)

Remember(if you are using notification services like oneSignal etc. make sure to check bundle version before archiving )

Comments

2

I had this issue today after upgrading my Xcode to 16.2; I looked everywhere but finally doing only these solved it for me:

  • flutter clean
  • flutter pub cache repair
  • flutter pub get

3 Comments

This was the answer that solved my headache. Thank you!
This didn't help :( getting this based on flutterfire: command not found error
one time I had this issue and when checking the (Target => Build Phases), I had an additional entry (FlutterFire: "flutterfire upload-crashlytics-symbols") that was added by default which was not important in my case since there was another script ([firebase_crashlytics] Crashlytics Upload Symbols) that was uploading the Crashlytics symbols normally, when removing it the error was gone.
1

For beginners: (tested on XCODE 12.0.1) open Xcode--> Open a project or file --> go to the flutter app path/ios directory--> open --> Runner and follow attached image steps enter image description here

2 Comments

As per this comment on GitHub: github.com/flutter/flutter/issues/99387#issuecomment-1081238267 this is a terrible advice and it will generate a new error Flutter/Flutter.h not found
@t3nsa you are absolutely correct.
1

Fix for me was force quitting Xcode. There recently was update, after which this issue appeared. After normal quitting and opening, there was error visible. But after force quitting and opening, Xcode showed dialog box, that some of its dependencies are missing and they will be downloaded. After that build was working for me again.

Comments

1

Easy way to fix this:

  1. Go to Menu -> System Preferences -> Security & Privacy.
  2. Choose the Privacy Tab.
  3. Select the Full Disk Access item in the left list.
  4. Select Xcode in the right list.

Source: https://github.com/flutter/flutter/issues/76302

Comments

1

I had a similar problem for Flutter, where my frameworks couldn't be resolved and I ended up here, so posting the solution to the problem in here.

Solution:

Update your pod version to match at least 1.12.1

Xcode 14.3 changed how they resolve symlinks to relative paths. So if you are below pod version 1.12.1 (mine was e.g. 1.11.3), if fails due to wrong path resolution and you either can go into: flutter-project/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh

and change:

source="$(readlink "${source}")"

to

source="$(readlink -f "${source}")"

Or you update your pod version to match at least 1.12.1

Hope that helps someone searching for this problem in flutter and having the same error message.

Comments

1

After running pod install in a Flutter iOS project, I encountered a Command PhaseScriptExecution error. The issue occurs because CocoaPods automatically sets project configuration files to Pods-Runner.debug.xcconfig and Pods-Runner.release.xcconfig. Solution:

Open your project in Xcode by double-clicking on the ios/Runner.xcworkspace file Select the Runner target Go to the Info tab In Configurations section:

For Debug configuration set Debug.xcconfig instead of Pods-Runner.debug.xcconfig For Release configuration set Release.xcconfig instead of Pods-Runner.release.xcconfig For Profile configuration set Release.xcconfig

enter image description here

Note: You'll need to repeat these steps each time after running pod install as CocoaPods overwrites these configuration settings. Why this works:

Flutter's default .xcconfig files already include necessary CocoaPods configurations This prevents conflicts between Flutter's build scripts and CocoaPods configuration It maintains proper integration with both Flutter and CocoaPods dependencies

Additional troubleshooting: If you still see errors after changing configurations, try:

flutter clean
cd ios
pod deintegrate
rm -rf Pods
rm Podfile.lock
pod install

1 Comment

this helped me, thanks
0

How I resolved this issue:

step 1: open up your flutter iOS directory in Xcode and try to build, it should give a more detailed overview of where the error is in your code.

PhaseScriptExecution failed with a nonzero exit code an error returned by Xcode build engine - you probably ignored warnings not obvious syntax error in your flutter code, could be a scope or imports declaration.

Ensure your build succeeds in Xcode before closing simulator.

Comments

0

Try to run sudo rm -rf /private/var/folders/* in Terminal. This resolves my problem.

Refer to: https://apple.stackexchange.com/a/176374/448505

Comments

0

This worked out strange for me.

There recently was an new update, after which this issue appeared. After normal quitting and opening, error was visible.

Force quit the xcode and rebuilding the app worked for me.

Comments

0

Building it from the CLI fixed it for me

flutter build ipa

Comments

0

I trying many things for me apps works after update flutter with flutter upgrade I hope works for you all also by the way ı update may mac and xcode also :)

Comments

0

TL;DR Try updating Flutter -> flutter upgrade

I had this error a few times and always try the flutter clean, flutter pub get...etc but it doesn't work for me. I also try restarting laptop, deleting recently added assets (as some comments suggest) but none of it works.

Then I remember how I fixed it last time by updating Flutter, and it has just worked for me again so definitely worth a try

Comments

0

sometimes it can be happen due to one of your outdated library that being used. try following command.

flutter pub upgrade --major-versions

after that run flutter pub get

Comments

0

This worked for me to generate an IPA file for deployment:

flutter build ipa --export-method development --no-tree-shake-icons

Comments

0

For Mac M1 developers

Follow the steps

1- Go to the iOS folder and delete the podfile.lock,pods

2- arch -x86_64 pod install may have to be used instead of pod install

Comments

0

I got this error after i update xcode. All that i did to resolve it was to upgrade flutter.

Comments

0

I tried everything and spent 3 to 4 days.

I found the solution with the below steps.

  1. Remove the iOS Folder of your Flutter project.

  2. Re-Create iOS Folder using the below command.

    flutter create -i swift .

  3. Go to iOS the iOS Folder and install pod.

    pod install

  4. Run the project. flutter run

Note: I know these steps are not always solved but it works for me.

I created this project with Flutter 2.2.3 (Dart 2.13.4) 2 or 3 years ago and never try to run it on iOS, Now Flutter running on 3.10.6 (Dart 3.0.6), and maybe some iOS project folder create with the old Drat Framework.

My system Dart Framework is always updated and tries to run with the old Dart compile version.

I think this one is in my case.

Comments

0

With my case, I try many another way not working. But final follow step below to fix:

  1. flutter clean
  2. flutter pub get
  3. cd ios & pod install

And last and most important, restart your MacBook because most of the time Xcode needs restart to adopt new changes.

1 Comment

This didn't help :( getting this based on flutterfire: command not found error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.