Flutter 1.22升级后,Flutter iOS构建失败

问题描述

我刚刚将Flutter版本升级到1.22.0。升级并为Firebase进行了一些更改后,我的Android应用开始工作,但无法在模拟器或物理设备上构建和运行iOS应用。

当我尝试在模拟器或物理设备中运行应用程序时,终端显示以下错误。模拟器运行在iOS 14上,而物理设备运行在14.0.1上。

Emulator: ld: symbol(s) not found for architecture x86_64
Actual device: ld: symbol(s) not found for architecture arm64

我还执行了以下命令,但仍然无法正常工作...

Flutter clean && \
rm ios/Podfile ios/Podfile.lock pubspec.lock && \
rm -rf ios/Pods ios/Runner.xcworkspace && \ 
Flutter run

Flutter Doctor:

[✓] Flutter (Channel stable,1.22.0,on Mac OS X 10.15.7 19H2,locale en-US)
    • Flutter version 1.22.0 at /Volumes/demouser/Flutter/FlutterSDK/Flutter
    • Framework revision d408d302e2 (7 days ago),2020-09-29 11:49:17 -0700
    • Engine revision 5babba6c4d
    • Dart version 2.10.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/demouserdemouser/Library/Android/sdk
    • 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_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1,Build version 12A7300
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

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

[✓] Connected device (1 available)
    • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!

pubspec.yaml

name: demo
description: demo
version: 1.0.0+1

environment:
  sdk: ">=2.5.2 <3.0.0"

dependencies:
  Flutter:
    sdk: Flutter

  cupertino_icons: ^1.0.0
  firebase_auth: ^0.18.1+1
  cloud_firestore: ^0.14.1+2
  firebase_messaging: ^6.0.16
  firebase_storage: ^5.0.0-dev.2
  firebase_core: ^0.5.0
  firebase_admob: ^0.10.0+1
  intl_translation: ^0.17.10+1
  http: ^0.12.2
  xml: ^4.5.1
  shared_preferences: ^0.5.12
  Flutter_staggered_grid_view: ^0.3.0
  Flutter_signin_button: ^1.0.0
  image_picker: ^0.6.7+11
  mlkit: ^0.15.1
  cached_network_image: ^2.3.2+1
  permission_handler: ^5.0.1+1
  url_launcher: ^5.7.2
  share: ^0.6.5+2
  simple_connectivity: ^0.1.1
  us_states: ^1.0.3
  cloud_functions: ^0.6.0+1
  email_validator: ^1.0.4
  package_info: ^0.4.3
  device_info: ^0.4.2+8
  expandable: ^4.1.4
  launch_review: ^2.0.0
  xml2json: ^4.4.0
  purchases_Flutter: ^1.3.1

dev_dependencies:
  Flutter_test:
    sdk: Flutter
  Flutter_launcher_icons: ^0.7.5

Flutter_icons:
  image_path: "icon/new_icon.png"
  android: false
  ios: true

端子的输出

> Launching lib/main.dart on physical iPhone in debug mode...
> Automatically signing iOS for device deployment using specified
> development team in Xcode project: 5ABCDEFG9 Running Xcode build...
> Xcode build done.                                           118.3s
> Failed to build iOS app Error output from Xcode build: ↳
>     2020-10-06 10:59:58.676 xcodebuild[7528:47880]  DTDeviceKit: deviceType from a578d1d6cb0d414525f7dc4c6cee was NULL
>     2020-10-06 10:59:58.778 xcodebuild[7528:47881]  DTDeviceKit: deviceType from a578d1d6cb0d414525f7dc4c6cee was NULL
>     2020-10-06 10:59:58.778 xcodebuild[7528:47881]  DTDeviceKit: deviceType from a578d1d6cb0d414525f7dc4c6cee was NULL
>     ** BUILD Failed **
Xcode's output:
↳
    /Volumes/driveD/Flutter/FlutterSDK/Flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.7.2/ios/Classes/FLTURLLauncherPlugin.m:153:57: warning: 'keyWindow' is deprecated: first deprecated in iOS 13.0 - Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes [-Wdeprecated-declarations]
                                                           .keyWindow.rootViewController];
                                                            ^
    In module 'UIKit' imported from /Volumes/driveD/projects/new/demo/ios/Pods/Target Support Files/url_launcher/url_launcher-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:134:51: note: 'keyWindow' has been explicitly marked deprecated here
    @property(nullable,nonatomic,readonly) UIWindow *keyWindow API_DEPRECATED("Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes",ios(2.0,13.0));


   -------
 ld: symbol(s) not found for architecture arm64
    clang: error: linker command Failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description

Could not build the precompiled application for the device.

Error launching application on physical’s iPhone.

该问题似乎是由于RevenueCat API引起的。当我在 pubspec.yaml 文件中注释了导入 purchases_Flutter 时,我能够安装该应用程序,但是在启动时崩溃,提示失去连接。

解决方法

关于stackoverflow,这里有两个不同的答案。如果我没记错的话,最后一次切换到“稳定”频道可以为我解决问题。

,

升级到1.22.0后,我也遇到了问题,我还必须升级flutterFire软件包,这似乎是我的问题。

我在pubspec.yaml上使用的版本:

  firebase_core: ^0.5.0
  cloud_firestore: ^0.14.1+2
  firebase_auth: ^0.18.1+1
  firebase_analytics: ^5.0.0
  cloud_functions: ^0.6.0+1
  firebase_storage: ^4.0.1
  firebase_crashlytics: ^0.1.0+3 
  firebase_messaging: ^7.0.2 

在尝试运行时,它说通过运行pod repo update来更新CocoaPods规格,虽然这样做,但是仍然遇到相同的错误,然后运行pod installpod update却得到了错误 enter image description here

尝试了以下命令:pod install --repo-updatepod update Firebase/Storage,但仍然收到相同的错误消息

,

rm -f ios / Runner.xcworkspace / xcshareddata / WorkspaceSettings.xcsettings为我解决了此问题

,

只需删除旧的flutter安装文件夹,例如[.cache] / [pub-cache],因为您可能已经升级了flutter版本,但是iOStools和其他工具指向的是旧版本,这会导致这些体系结构问题。

,

最后,在进行了很多更改之后,我发现罪魁祸首是 purchases_flutter:^ 1.3.1 ”软件包。

当我从yaml文件中删除该软件包时,它便开始工作。 https://github.com/RevenueCat/purchases-flutter/issues/120已经打开了一个错误。

感谢大家的时间和帮助。

,

我有类似的错误 ld:找不到架构x86_64的符号 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用) 注意:使用新的构建系统 注意:并行建立目标 注意:规划构建 注意:构建版本说明