error: Build input file cannot be found: '/Users/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')

error: Build input file cannot be found: '/Users/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')

我正在尝试构建 Flutter 项目的 iOS。无论我尝试什么,它都会给我以下错误:

error: Build input file cannot be found: '/Users/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')

这是我试图通过以下方式获取构建的命令集:

这是我的 flutter doctor 输出

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.16.3-pre.67, on Mac OS X 10.15.3 19D76, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.43.2)
[!] Connected device

! Doctor found issues in 1 category.

flutter build ios --verbose 以以下错误结束:

Encountered error while building for the device.

#0      throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
#1      BuildIOSCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:93:7)
<asynchronous suspension>
#2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:722:18)
#3      _rootRunUnary (dart:async/zone.dart:1155:38)
#4      _CustomZone.runUnary (dart:async/zone.dart:1048:19)
#5      _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#6      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#7      Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#8      Future._completeWithValue (dart:async/future_impl.dart:526:5)
#9      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:556:7)
#10     _rootRun (dart:async/zone.dart:1147:13)
#11     _CustomZone.run (dart:async/zone.dart:1040:19)
#12     _CustomZone.runGuarded (dart:async/zone.dart:942:7)
#13     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:982:23)
#14     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#15     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#16     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#17     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)

这是文件夹结构的图像。如您所见,没有包含 Google plist 的 'Users' 文件夹。因此,令人困惑的是为什么脚本会尝试从不存在的目录中复制 plist。任何解决此问题的建议将不胜感激。 TIA :-)

删除 GoogleService-Info.plist,然后使用 Xcode 再次将文件添加到 Runner 目录,然后选择 copy items if neededadd to target 复选标记。我希望这能解决你的问题。

最终我找到了修复它的方法:

  1. 从 Firebase 下载新的 GoogleService-Info.plist 文件

  2. 将其放在 flutter 项目的 ios/Runner 目录中(将 GoogleService-Info.plist 放入 Runner 目录中,而不是 XCode)

  3. 打开 XCode 和打开 ios/Runner.xcworkspace

  4. 在 XCode 中,将文件 GoogleService-Info.plist 从您的查找器拖到蓝色 RunnerProject 下方的黄色 Runner 文件夹(在项目导航器左侧屏幕)

  1. 接下来,flutter run