Flutter:Firebase_Analytics-体系结构x86_64的未定义符号:“ _ OBJC_CLASS _ $ _ FIRAnalytics”,引用自:

时间:2020-09-02 12:27:33

标签: swift xcode flutter dart

我已将Flutter更新至最新版本1.20,并执行了Xcode 11.4支持的步骤。执行完这些步骤后,获得了与架构相关的错误。

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_FIRAnalytics", referenced from:
      objc-class-ref in firebase_analytics(FLTFirebaseAnalyticsPlugin.o)
     (maybe you meant: _OBJC_CLASS_$_FIRAnalyticsConfiguration)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
  • 扑打医生:
[✓] Flutter (Channel stable, 1.20.0, on Mac OS X 10.15.6 19G73, locale en-US)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 3.6)
[✓] IntelliJ IDEA Community Edition (version 2019.2.2)
[✓] Connected device (2 available)

• No issues found!

此外,我正在pubspec.yaml中使用firebase_analytics的最新版本: ^ 6.0.0

  • iOS Podfile:
     platform :ios, '9.0'
    
    # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
    ENV['COCOAPODS_DISABLE_STATS'] = 'true'
    
    project 'Runner', {
      'Debug' => :debug,
      'Profile' => :release,
      'Release' => :release,
    }
    
    def flutter_root
      generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
      unless File.exist?(generated_xcode_build_settings_path)
        raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
      end
      
      File.foreach(generated_xcode_build_settings_path) do |line|
        matches = line.match(/FLUTTER_ROOT\=(.*)/)
        return matches[1].strip if matches
      end
      raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
    end
    
    require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
    
    flutter_ios_podfile_setup
    
    target 'Runner' do
      use_frameworks!
      use_modular_headers!
      
      pod 'Firebase/Core'
      pod 'NVActivityIndicatorView', '~> 4.8.0'
      pod 'SwiftyUserDefaults', '~> 3.0.0'
      pod 'RSMasterTableView', :git => 'https://github.com/DhavalRKansara/RSMasterTableView.git'
      pod 'CryptoSwift'
      pod 'SwiftR' , :git => 'https://github.com/DhavalRKansara/SwiftR.git'
      pod 'SKPhotoBrowser'
      pod 'RSSelectionMenu'
      pod 'JJFloatingActionButton'
      pod 'MaterialComponents/TextFields'
      pod 'MarqueeLabel'
      pod 'Firebase/Analytics'
      
      flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
    end
    
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
      end
    end   

注意:我也提出了与issue一起在GitHub扑朔迷离的情况。

1 个答案:

答案 0 :(得分:0)

您的Xcode项目的目标是x86_64,适用于MacOS。 您将需要回滚到arm64,或者可以运行以下命令将iOS项目重新创建为其默认设置(请确保先备份flutter项目):(仅当您未进行任何更改时才运行此命令)专门针对xcode项目,例如资产或图标)

flutter create  -i swift .

或对于目标c:

flutter create  -i objc .

如果您确实需要为MacOS开发,则需要在flutter项目(https://flutter.dev/desktop)上创建一个单独的macos文件夹。

运行以下命令:

flutter channel dev

切换到Alpha通道(MacOS仍然不稳定)

flutter upgrade

flutter config --enable-macos-desktop

然后重新启动IDE,如果在flutter项目中看不到macos文件夹,请运行以下命令:

flutter create .

这将添加/修复所有丢失的文件(确保首先备份您的项目)。 然后只需运行以下命令即可为macos进行部署:

flutter run -d macos --release