Flutter ios 构建失败。模拟器构建也失败

Flutter ios build fails. simulator builds also fail

几个月来我一直在开发一个应用程序并使用 Flutter,但是每当我升级 Flutter 时,它是一个巨大的痛苦,因为我必须努力让它重新建立起来。平时手动清理CocoaPodspubspec.yaml就够了,这次不行。

我已将我的 Flutter 版本从 1.10.7 升级到 1.14.6 , 破坏了我的 podspubspec.yaml, 破坏了我安装的 Flutter ,我的存储库,但没有任何效果。

另一个奇怪的事情是,我的构建 运行 与相同版本的 flutter、dart、cocoapods 和 ruby 在同一分支上不同的机器。是否有缓存的东西我没有正确清理?当我尝试构建时,它说它因错误而失败,但不幸的是,日志输出实际上并未显示任何错误,仅显示警告。这是我的日志输出的一部分:

8 warnings generated.
    /Users/hallo/Documents/dev/flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in-4.1.1/ios/Classes/FLTGoogleSignInPlugin.m:138:13: warning: unused variable 'sourceApplication' [-Wunused-variable]
      NSString *sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey];
                ^
    /Users/hallo/Documents/dev/flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in-4.1.1/ios/Classes/FLTGoogleSignInPlugin.m:138:41: warning: 'UIApplicationOpenURLOptionsSourceApplicationKey' is only available on iOS 9.0 or newer [-Wunguarded-availability]
      NSString *sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey];
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In module 'UIKit' imported from /Users/hallo/Documents/HalloMonoRepo/hallo/ios/Pods/Target Support Files/google_sign_in/google_sign_in-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:514:51: note: 'UIApplicationOpenURLOptionsSourceApplicationKey' has been marked as being introduced in iOS 9.0 here, but the deployment target is iOS 8.0.0
    UIKIT_EXTERN UIApplicationOpenURLOptionsKey const UIApplicationOpenURLOptionsSourceApplicationKey NS_SWIFT_NAME(sourceApplication) API_AVAILABLE(ios(9.0));   // value is an NSString containing the bundle ID of the originating application; non-nil if the originating application and this application share the same team identifier
                                                      ^
    /Users/hallo/Documents/dev/flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in-4.1.1/ios/Classes/FLTGoogleSignInPlugin.m:138:41: note: enclose 'UIApplicationOpenURLOptionsSourceApplicationKey' in an @available check to silence this warning
      NSString *sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey];
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Could not build the application for the simulator.
Error launching application on iPhone 8.

任何帮助将不胜感激,因为我已经用尽了所有可能导致此错误的想法。

Pluto:hallo hallo$ flutter doctor -v
[✓] Flutter (Channel beta, v1.14.6, on Mac OS X 10.14.6 18G3020, locale en-US)
• Flutter version 1.14.6 at /Users/hallo/Documents/dev/flutter
• Framework revision fabeb2a16f (3 weeks ago), 2020-01-28 07:56:51 -0800
• Engine revision c4229bfbba
• Dart version 2.8.0 (build 2.8.0-dev.5.0 fc3af737c7)


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/hallo/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.0, Build version 11A420a
• CocoaPods version 1.8.4

[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 39.0.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.42.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.8.1

[✓] Connected device (1 available)
• iPhone 8 • C40DD8DB-5860-4B94-8D20-372074B6E7BC • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-0 (simulator)

• No issues found!`

你 运行 在 Android 工作室吗? VS代码?你能 post 你的 flutter doctor -v 吗?

除此之外,所有这些错误都来自 google_sign_in。会推荐以下内容:

  • 删除 google_sign_in(并评论使用此依赖项的任何屏幕)
  • 确保您遵循 iOS Folder
  • 中的所有正确更改
  • 使用不同的库。 google_sign_in 可能未与所有最新的 Flutter 更改同步。

如果您的代码在没有该库的情况下运行,它会清楚地显示最新升级更改的错误。

我通过更改各种内容解决了这个问题。当我进行 flutter 升级时,它通过添加此行

更改了我的 project.pbxproj 文件

shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\"${PODS_ROOT}/Fabric/run\"\n"; 这导致了很多错误。我删除了这一行,将 Xcode 中的构建系统更改为默认值(这是遗留的),然后在 Xcode 中的嵌入框架中,我删除了 Flutter.framework。

只是 运行 flutter clean 在你的项目上,它对我有用。