如何解决 Flutter iOS 中的“Command PhaseScriptExecution failed with a nonzero exit code”

Zen*_*nko 10 xcode ios flutter

我在这个问题上浪费了将近一周的时间却毫无结果。

\n

这是错误:

\n
Failed to build iOS app\nError output from Xcode build:\n\xe2\x86\xb3\n    ** BUILD FAILED **\n\n\nXcode\'s output:\n\xe2\x86\xb3\n    Writing result bundle at path:\n        /var/folders/fq/7j2x58m57c9bk10jg7q47krr0000gn/T/flutter_tools.vyKPSp/flutter_ios_build_temp_di\n        rGZCufm/temporary_xcresult_bundle\n\n\n    Failed to package /Volumes/ME/Projects/Flutter-Proj/app.\n    Command PhaseScriptExecution failed with a nonzero exit code\n    note: Building targets in dependency order\n    warning: Run script build phase \'Create Symlinks to Header Folders\' will be run during every\n    build because it does not specify any outputs. To address this warning, either add output\n    dependencies to the script phase, or configure it to run in every build by unchecking "Based on\n    dependency analysis" in the script phase. (in target \'BoringSSL-GRPC\' from project \'Pods\')\n    warning: Run script build phase \'Create Symlinks to Header Folders\' will be run during every\n    build because it does not specify any outputs. To address this warning, either add output\n    dependencies to the script phase, or configure it to run in every build by unchecking "Based on\n    dependency analysis" in the script phase. (in target \'abseil\' from project \'Pods\')\n    warning: Run script build phase \'Create Symlinks to Header Folders\' will be run during every\n    build because it does not specify any outputs. To address this warning, either add output\n    dependencies to the script phase, or configure it to run in every build by unchecking "Based on\n    dependency analysis" in the script phase. (in target \'Libuv-gRPC\' from project \'Pods\')\n    warning: Run script build phase \'Create Symlinks to Header Folders\' will be run during every\n    build because it does not specify any outputs. To address this warning, either add output\n    dependencies to the script phase, or configure it to run in every build by unchecking "Based on\n    dependency analysis" in the script phase. (in target \'gRPC-Core\' from project \'Pods\')\n    warning: Run script build phase \'Create Symlinks to Header Folders\' will be run during every\n    build because it does not specify any outputs. To address this warning, either add output\n    dependencies to the script phase, or configure it to run in every build by unchecking "Based on\n    dependency analysis" in the script phase. (in target \'gRPC-C++\' from project \'Pods\')\n    warning: Run script build phase \'Run Script\' will be run during every build because it does not\n    specify any outputs. To address this warning, either add output dependencies to the script\n    phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the\n    script phase. (in target \'Runner\' from project \'Runner\')\n    note: Run script build phase \'Thin Binary\' will be run during every build because the option to\n    run the script phase "Based on dependency analysis" is unchecked. (in target \'Runner\' from\n    project \'Runner\')\n    warning: Run script build phase \'[firebase_crashlytics] Crashlytics Upload Symbols\' will be run\n    during every build because it does not specify any outputs. To address this warning, either add\n    output dependencies to the script phase, or configure it to run in every build by unchecking\n    "Based on dependency analysis" in the script phase. (in target \'Runner\' from project \'Runner\')\n\n    Result bundle written to path:\n        /var/folders/fq/7j2x58m57c9bk10jg7q47krr0000gn/T/flutter_tools.vyKPSp/flutter_ios_build_temp_di\n        rGZCufm/temporary_xcresult_bundle\n\n\nCould not build the precompiled application for the device.\n\nError launching application on iPhone.\n
Run Code Online (Sandbox Code Playgroud)\n

这些是我尝试过的事情:

\n
    \n
  1. 清爽的 Flutter 和 Pod

    \n
      \n
    • rm Podfile.lock
    • \n
    • flutter clean
    • \n
    • flutter pub get
    • \n
    • pod repo update
    • \n
    • pod install
    • \n
    \n
  2. \n
  3. 清除 pod 缓存并重做上述操作。

    \n
  4. \n
  5. 重新安装了 Xcode、Flutter、Android Studio。

    \n
  6. \n
  7. 选中/取消选中For install builds only和/或Based on dependency analysis

    \n
  8. \n
  9. 遵循了多种解决方案:[此处](How to fix Command PhaseScriptExecution failed with a nonzero exit code on flutter run in macOS?),[此处](Command PhaseScriptExecution failed with a nonzero exit code while attempts to add Flutter to iOS app) ,以及[此处](Flutter 无法打包。命令 PhaseScriptExecution 失败,退出代码非零)。还有很多类似的。

    \n
  10. \n
  11. 使用以下命令检查所有 PNG 文件是否有错误pngcheck

    \n
  12. \n
\n

以上都不起作用。

\n

[更新]\n7。试图购买一台全新安装的新电脑。仍然不起作用。\n8. 尝试重新创建 Flutter 应用程序。

\n

我的flutter doctor -v

\n
[\xe2\x9c\x93] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-x64, locale en-US)\n    \xe2\x80\xa2 Flutter version 3.3.4 on channel stable at /Users/ME/development/flutter\n    \xe2\x80\xa2 Upstream repository https://github.com/flutter/flutter.git\n    \xe2\x80\xa2 Framework revision eb6d86ee27 (5 days ago), 2022-10-04 22:31:45 -0700\n    \xe2\x80\xa2 Engine revision c08d7d5efc\n    \xe2\x80\xa2 Dart version 2.18.2\n    \xe2\x80\xa2 DevTools version 2.15.0\n    \xe2\x80\xa2 Pub download mirror https://pub.flutter-io.cn\n    \xe2\x80\xa2 Flutter download mirror https://storage.flutter-io.cn\n\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android SDK version 32.0.0)\n    \xe2\x80\xa2 Android SDK at /Volumes/ME/Applications/Android/sdk\n    \xe2\x80\xa2 Platform android-32, build-tools 32.0.0\n    \xe2\x80\xa2 ANDROID_HOME = /Volumes/ME/Applications/Android/sdk\n    \xe2\x80\xa2 Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java\n    \xe2\x80\xa2 Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)\n    \xe2\x80\xa2 All Android licenses accepted.\n\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS (Xcode 14.0.1)\n    \xe2\x80\xa2 Xcode at /Applications/Xcode.app/Contents/Developer\n    \xe2\x80\xa2 Build 14A400\n    \xe2\x80\xa2 CocoaPods version 1.11.3\n\n[\xe2\x9c\x93] Chrome - develop for the web\n    \xe2\x80\xa2 Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome\n\n[\xe2\x9c\x93] Android Studio (version 2021.2)\n    \xe2\x80\xa2 Android Studio at /Applications/Android Studio.app/Contents\n    \xe2\x80\xa2 Flutter plugin can be installed from:\n       https://plugins.jetbrains.com/plugin/9212-flutter\n    \xe2\x80\xa2 Dart plugin can be installed from:\n       https://plugins.jetbrains.com/plugin/6351-dart\n    \xe2\x80\xa2 Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)\n\n[\xe2\x9c\x93] VS Code (version 1.71.2)\n    \xe2\x80\xa2 VS Code at /Applications/Visual Studio Code.app/Contents\n    \xe2\x80\xa2 Flutter extension version 3.48.0\n\n[\xe2\x9c\x93] Connected device (3 available)\n    \xe2\x80\xa2 iPho (mobile) \xe2\x80\xa2 00012101-001965606543001E \xe2\x80\xa2 ios            \xe2\x80\xa2 iOS 15.6.1 19G82\n    \xe2\x80\xa2 macOS (desktop)     \xe2\x80\xa2 macos                     \xe2\x80\xa2 darwin-x64     \xe2\x80\xa2 macOS 12.6 21G115\n      darwin-x64\n    \xe2\x80\xa2 Chrome (web)        \xe2\x80\xa2 chrome                    \xe2\x80\xa2 web-javascript \xe2\x80\xa2 Google Chrome\n      105.0.5195.125\n\n[\xe2\x9c\x93] HTTP Host Availability\n    \xe2\x80\xa2 All required HTTP hosts are available\n\n\xe2\x80\xa2 No issues found!\n
Run Code Online (Sandbox Code Playgroud)\n

小智 2

请按照以下步骤操作

  1. 进入iOS文件夹,删除podfile.lock、pods、xcworkspace
  2. 进入根文件夹并使用 flutter clean
  3. 扑扑酒吧得到
  4. 转到 iOS 文件夹并安装用户 pod

N:B:请记住删除 xcworkspace 文件,否则它将无法工作并检查您的 pod 是否已更新。如果您的 pod 未更新,请使用 pod repo update。