【问题标题】:Flutter: Firebase_Analytics - Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_FIRAnalytics", referenced from:Flutter:Firebase_Analytics - 架构 x86_64 的未定义符号:“_OBJC_CLASS_$_FIRAnalytics”,引用自:
【发布时间】:2020-12-21 14:55:55
【问题描述】:

我已将 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   

注意:我也在 GitHub 上的 flutterfire 下提出了和issue 相同的问题。

【问题讨论】:

    标签: swift xcode flutter dart


    【解决方案1】:

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

    flutter create  -i swift .
    

    或者对于objective-c:

    flutter create  -i objc .
    

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

    运行这些命令:

    flutter channel dev
    

    切换到 alpha 通道(MacOS 对于 Flutter 仍然不稳定)

    flutter upgrade
    
    flutter config --enable-macos-desktop
    

    然后重启IDE,如果你在你的flutter项目中看不到macos文件夹,运行这个命令:

    flutter create .
    

    这将添加/修复任何丢失的文件(确保首先支持您的项目)。 然后简单地运行这个命令来部署 macOS:

    flutter run -d macos --release 
    

    【讨论】:

      猜你喜欢
      • 2016-11-12
      • 2018-06-23
      • 1970-01-01
      • 2020-01-24
      • 1970-01-01
      • 1970-01-01
      • 2015-10-27
      • 2019-01-01
      • 2018-03-28
      相关资源
      最近更新 更多