如何修复在 macOS 中运行 flutter 时命令 PhaseScriptExecution 失败并出现非零退出代码的问题?

Bha*_*oha 8 xcode ios flutter

我正在开发一个颤振应用程序。我最近转移到 macOS,从那时起就无法运行该应用程序。其他应用程序运行良好,因此我认为错误出在该应用程序的代码中。也许由于同样的原因,我无法进行构建。

\n

这是输出flutter doctor

\n
[\xe2\x9c\x93] Flutter (Channel stable, 1.20.1, on Mac OS X 10.15.6 19G73, locale en-US)\n    \xe2\x80\xa2 Flutter version 1.20.1 at /Users/bhawna/dev/flutter\n    \xe2\x80\xa2 Framework revision 2ae34518b8 (4 days ago), 2020-08-05 19:53:19 -0700\n    \xe2\x80\xa2 Engine revision c8e3b94853\n    \xe2\x80\xa2 Dart version 2.9.0\n\n[\xe2\x9c\x97] Android toolchain - develop for Android devices\n    \xe2\x9c\x97 Unable to locate Android SDK.\n      Install Android Studio from: https://developer.android.com/studio/index.html\n      On first launch it will assist you in installing the Android SDK components.\n      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).\n      If the Android SDK has been installed to a custom location, set ANDROID_SDK_ROOT to that location.\n      You may also want to add it to your PATH environment variable.\n\n\n \n[\xe2\x9c\x93] Xcode - develop for iOS and macOS (Xcode 11.6)\n    \xe2\x80\xa2 Xcode at /Applications/Xcode.app/Contents/Developer\n    \xe2\x80\xa2 Xcode 11.6, Build version 11E708\n    \xe2\x80\xa2 CocoaPods version 1.9.3\n\n[!] Android Studio (not installed)\n    \xe2\x80\xa2 Android Studio not found; download from https://developer.android.com/studio/index.html\n      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).\n\n[\xe2\x9c\x93] VS Code (version 1.47.3)\n    \xe2\x80\xa2 VS Code at /Applications/Visual Studio Code.app/Contents\n    \xe2\x80\xa2 Flutter extension version 3.13.2\n\n \n[\xe2\x9c\x93] Connected device (1 available)            \n    \xe2\x80\xa2 iPhone 8 (mobile) \xe2\x80\xa2 3D03BDE4-F1A6-45AB-B095-01107CDDC2CD \xe2\x80\xa2 ios \xe2\x80\xa2 com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)\n
Run Code Online (Sandbox Code Playgroud)\n

输出flutter run

\n
Running "flutter pub get" in delivero...                            1.6s\nLaunching lib/main.dart on iPhone 8 in debug mode...\n \nRunning pod install...                                             38.2s\nRunning Xcode build...                                                  \n                                                   \nXcode build done.                                           449.0s\nFailed 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    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inapp_purchase-2.2.0/ios/Classes/FlutterInappPurchasePlugin.\n    m:45:52: warning: assigning to 'id<IAPPromotionObserverDelegate>' from incompatible type 'FlutterInappPurchasePlugin *__strong'\n        [IAPPromotionObserver sharedObserver].delegate = self;\n                                                       ^ ~~~~\n    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inapp_purchase-2.2.0/ios/Classes/FlutterInappPurchasePlugin.\n    m:200:79: warning: implicit conversion loses integer precision: 'SKPaymentTransactionState' (aka 'enum\n    SKPaymentTransactionState') to 'int' [-Wshorten-64-to-32]\n                                                         [NSNumber numberWithInt: item.transactionState], @"transactionStateIOS",\n                                                         ~                        ^~~~~~~~~~~~~~~~~~~~~\n    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inapp_purchase-2.2.0/ios/Classes/FlutterInappPurchasePlugin.\n    m:586:71: warning: implicit conversion loses integer precision: 'SKPaymentTransactionState' (aka 'enum\n    SKPaymentTransactionState') to 'int' [-Wshorten-64-to-32]\n                                                 [NSNumber numberWithInt: transaction.transactionState], @"transactionStateIOS",\n                                                 ~                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n    3 warnings generated.\n    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/contacts_service-0.3.10/ios/Classes/ContactsServicePlugin.m:6:4:\n    warning: 'SwiftContactsServicePlugin' is only available on iOS 9.0 or newer [-Wunguarded-availability]\n      [SwiftContactsServicePlugin registerWithRegistrar:registrar];\n       ^~~~~~~~~~~~~~~~~~~~~~~~~~\n    In file included from\n    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/contacts_service-0.3.10/ios/Classes/ContactsServicePlugin.m:2:\n    /Users/bhawna/delivero/delivero/build/ios/Debug-iphonesimulator/contacts_service/contacts_service.framework/Headers/contacts_serv\n    ice-Swift.h:213:12: note: 'SwiftContactsServicePlugin' has been marked as being introduced in iOS 9.0 here, but the deployment\n    target is iOS 8.0.0\n    @interface SwiftContactsServicePlugin : NSObject <FlutterPlugin>\n               ^\n    /Users/bhawna/dev/flutter/.pub-cache/hosted/pub.dartlang.org/contacts_service-0.3.10/ios/Classes/ContactsServicePlugin.m:6:4:\n    note: enclose 'SwiftContactsServicePlugin' in an @available check to silence this warning\n      [SwiftContactsServicePlugin registerWithRegistrar:registrar];\n       ^~~~~~~~~~~~~~~~~~~~~~~~~~\n    1 warning generated.\n    /Users/bhawna/dev/flutter/packages/flutter_tools/bin/xcode_backend.sh: line 13: pushd: /Users/hrvoje/Documents/Delivero\n    Files/contactsFeature: No such file or directory\n    Command PhaseScriptExecution failed with a nonzero exit code\n    note: Using new build system\n    note: Building targets in parallel\n    note: Planning build\n    note: Constructing build description\n\nCould not build the application for the simulator.\nError launching application on iPhone 8.\n
Run Code Online (Sandbox Code Playgroud)\n

任何帮助都会很棒。谢谢你的时间。

\n

小智 13

经过 2 天的努力,简单的命令使我的归档成功:

flutter clean
flutter pub get
flutter pub upgrade
cd iOS
pod install
pod update 
Run Code Online (Sandbox Code Playgroud)

问题已经解决了。


Jef*_* S. 9

您可能不会相信,但就我而言,问题是由用于生成启动器图标的损坏图像引起的。Alpha 通道有些混乱。我修复后,产品可以成功归档。

  • 太不可思议了。我将我的 flutter 资源中的 jpg 替换为 png,并开始出现此构建错误。尝试了一个小时的所有可能的方法,直到我找到这个响应,将 jpg 放回去,现在一切正常。我无法理解,在没有任何额外信息的情况下,如此小的更改如何会严重破坏构建。 (3认同)
  • 我的上帝!!这!!!我看到这个评论并想“当然不可能是这样。在迁移到空安全之前一切都工作正常”,但在被卡住几周后,结果却是这样。以下是我找到罪魁祸首的方法:Flutter Clean - Comment out all image asset in pubspec - flutter pub get。运行应用程序。此时,我的应用程序再次开始工作。然后,逐一取消注释图像资产 - flutter pub get - 运行应用程序。我有两个 PNG 引起了问题。我只需在 Photoshop 中打开它们并将它们重新保存为 PNG 就可以了。 (2认同)

小智 0

  1. 删除podfile.lock
  2. iOS>pod 安装
  3. 扑干净
  4. 扑腾跑


归档时间:

查看次数:

27135 次

最近记录:

2 年 前