flutterxcodemacosdartxcode8

Cannot start my flutter app on an Iphone device for debugging on Mac M1


When I try to start the app, I get the following error.

Xcode build done.                                           18.7s

Failed to build iOS app

Could not build the precompiled application for the device.

Error output from Xcode build:


↳


    ** BUILD FAILED **


2



Xcode's output:


↳


    Writing result bundle at path:


        /var/folders/gx/0xqx8frn70b6846551t3qqtc0000gn/T/flutter_tools.0BGX7l/flutter_ios_build_temp_dir5JolwN/temporary_xcresult_bundle





5
    ld: warning: ignoring duplicate libraries: '-lc++'


    Unhandled exception:


    Null check operator used on a null value


    #0      Context.embedFlutterFrameworks (file:///Users/userabc/Developer/Tools/flutter/packages/flutter_tools/bin/xcode_backend.dart:235:68)


    #1      Context.run (file:///Users/userabc/Developer/Tools/flutter/packages/flutter_tools/bin/xcode_backend.dart:59:9)


    #2      main (file:///Users/userabc/Developer/Tools/flutter/packages/flutter_tools/bin/xcode_backend.dart:17:5)


    #3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)


    #4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)


    Command PhaseScriptExecution failed with a nonzero exit code


    warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'abseil' from project 'Pods')


    warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'BoringSSL-GRPC' from project 'Pods')


    warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'gRPC-Core' from project 'Pods')


    warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'gRPC-C++' from project 'Pods')


    note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')


    note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')

I tried:

cd ios
sudo arch -x86_64 gem install ffi
arch -x86_64 pod repo update
arch -x86_64 pod install

It did not work at all.

> flutter --version
     Flutter 3.22.2 • channel stable • https://github.com/flutter/flutter.git
     Framework • revision 761747bfc5 (5 days ago) • 2024-06-05 22:15:13 +0200
     Engine • revision edd8546116
     Tools • Dart 3.4.3 • DevTools 2.34.3

> pod --version
     1.15.2

And if I run flutter doctor -v it says No issues found.

I spent hours on it with no success. Anyone who may have had the problem and solved it as well..?


Solution

  • This appears to be a Flutter problem, which they could not solve for months for some reason.

    This thread is explaining the issue: https://github.com/flutter/flutter/issues/140845

    The problem appears to be that FLUTTER_BUILD_DIR cannot be found/identified as environment variable. Updating Debug, Release and Profile info in Configurations solved the problem as explained in the GitHub issue given in the link above.