架构为 x86_64 的 Flutter 中未定义的符号

21

我正在使用Flutter开发一个应用程序。在Android上一切正常,但在iOS上出现了问题。我需要一些帮助来在iOS手机上运行它。我使用的库是:google_maps_flutter: ^0.5.27+3firebase_ml_vision: ^0.9.3+8。Xcode版本为11.4.1,Mac OS版本为Catalina 10.15.4。有人知道如何解决这个问题吗?我还没有找到解决方法。

flutter doctor
[✓] Flutter (Channel stable, v1.17.0, on Mac OS X 10.15.4 19E287, locale en-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.45.0)
[✓] Connected device (1 available)

• No issues found!

以下是日志记录的错误信息:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_GMSPolyline", referenced from:
      objc-class-ref in google_maps_flutter(GoogleMapPolylineController.o)
  "_OBJC_CLASS_$_FIRVisionOnDeviceImageLabelerOptions", referenced from:
      objc-class-ref in firebase_ml_vision(ImageLabeler.o)
  "_FIRFaceLandmarkTypeLeftEar", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceLandmarkTypeMouthLeft", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceLandmarkTypeRightCheek", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceLandmarkTypeNoseBase", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceLandmarkTypeRightEye", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_OBJC_CLASS_$_GMSMarker", referenced from:
      objc-class-ref in google_maps_flutter(GoogleMapMarkerController.o)
  "_FIRFaceLandmarkTypeMouthRight", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceContourTypeLeftEye", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceContourTypeRightEye", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceContourTypeLowerLipTop", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_OBJC_CLASS_$_GMSServices", referenced from:
      objc-class-ref in AppDelegate.o
  "_FIRFaceContourTypeNoseBottom", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceLandmarkTypeLeftCheek", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceLandmarkTypeLeftEye", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_OBJC_CLASS_$_GMSMapStyle", referenced from:
      objc-class-ref in google_maps_flutter(GoogleMapController.o)
  "_FIRFaceContourTypeRightEyebrowTop", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_OBJC_CLASS_$_GMSPolygon", referenced from:
      objc-class-ref in google_maps_flutter(GoogleMapPolygonController.o)
  "_FIRFaceContourTypeUpperLipTop", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceContourTypeRightEyebrowBottom", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceContourTypeLeftEyebrowBottom", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceLandmarkTypeRightEar", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceContourTypeUpperLipBottom", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_OBJC_CLASS_$_FIRVisionCloudImageLabelerOptions", referenced from:
      objc-class-ref in firebase_ml_vision(ImageLabeler.o)
  "_OBJC_CLASS_$_GMSCameraPosition", referenced from:
      objc-class-ref in google_maps_flutter(GoogleMapController.o)
  "_kGMSMinZoomLevel", referenced from:
      _InterpretMapOptions in google_maps_flutter(GoogleMapController.o)
  "_OBJC_CLASS_$_GMSMapView", referenced from:
      objc-class-ref in google_maps_flutter(GoogleMapController.o)
  "_OBJC_CLASS_$_GMSMutablePath", referenced from:
      objc-class-ref in google_maps_flutter(GoogleMapPolygonController.o)
      objc-class-ref in google_maps_flutter(GoogleMapPolylineController.o)
  "_OBJC_CLASS_$_GMSCircle", referenced from:
      objc-class-ref in google_maps_flutter(GoogleMapCircleController.o)
  "_FIRFaceLandmarkTypeMouthBottom", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_OBJC_CLASS_$_GMSCoordinateBounds", referenced from:
      objc-class-ref in google_maps_flutter(GoogleMapController.o)
  "_OBJC_CLASS_$_GMSCameraUpdate", referenced from:
      objc-class-ref in google_maps_flutter(GoogleMapController.o)
  "_FIRFaceContourTypeLeftEyebrowTop", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_OBJC_CLASS_$_FIRVision", referenced from:
      objc-class-ref in firebase_ml_vision(FLTFirebaseMlVisionPlugin.o)
  "_OBJC_CLASS_$_FIRVisionFaceDetectorOptions", referenced from:
      objc-class-ref in firebase_ml_vision(FaceDetector.o)
  "_kGMSMaxZoomLevel", referenced from:
      _InterpretMapOptions in google_maps_flutter(GoogleMapController.o)
  "_FIRFaceContourTypeAll", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_OBJC_CLASS_$_FIRVisionBarcodeDetectorOptions", referenced from:
      objc-class-ref in firebase_ml_vision(BarcodeDetector.o)
  "_OBJC_CLASS_$_FIRApp", referenced from:
      objc-class-ref in firebase_ml_vision(FLTFirebaseMlVisionPlugin.o)
  "_FIRFaceContourTypeLowerLipBottom", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_OBJC_CLASS_$_FIRVisionImage", referenced from:
      objc-class-ref in firebase_ml_vision(FLTFirebaseMlVisionPlugin.o)
  "_FIRFaceContourTypeFace", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
  "_FIRFaceContourTypeNoseBridge", referenced from:
      ___39-[FaceDetector handleDetection:result:]_block_invoke in firebase_ml_vision(FaceDetector.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

你的物理设备(iPhone)有问题吗? - Carla Camargo
1
我有一个使用Objective-C编写的Flutter项目,但尝试使用Swift代码插件。重新用Swift创建Flutter项目解决了我的问题。 - Pavel
3个回答

27

可能出错的原因在于某些XCode项目文件,请尝试:

  1. 备份你的项目。
  2. 运行如下命令

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

参考链接


3
我不得不运行分离的代码,但它可以工作。非常感谢 :) - Dansp
6
完美 - 很有效,谢谢。对于 Mac,我使用了以下命令:flutter clean; rm ios/Podfile ios/Podfile.lock pubspec.lock; rm -rf ios/Pods ios/Runner.xcworkspace; flutter run - Rhisiart
对我来说,这个答案没有起作用。我正在开发一个Flutter插件,在我的情况下,解决方案是在我的插件的podspec文件中添加s.static_framework = true这一行。希望这能帮助到某些人。 - ddalbosco
完美。它可以工作。 - Muhammad Tameem Rafay
1
这对我也没用。 - SULPHURIC ACID
对我不起作用 :( - Soorya

4

在搭载M1芯片的Mac上,我无法在模拟器中运行我的项目,不过我可以使用连接的实体iPhone代替,它不会显示错误并且可以正常运行。


2
你找到在模拟器上运行它的解决方案了吗? - Oleksandr

1
这个错误的关键部分可能是“ld: symbol(s) not found for architecture x86_64”,似乎与处理器架构有关,因此请尝试在终端或VS Code中导航到您的项目文件夹并使用以下命令:

open iOS/Runner.xcworkspace

确保iOS部署目标设置正确。出于某种莫名其妙的原因,我的设置为iOS 11.0。我将其更改为iOS 16.0,问题得到了解决。

在“PROJECT”部分更改为适当的iOS版本

在“TARGETS”部分也进行更改


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接