Firebase 未定义符号

Posted

技术标签:

【中文标题】Firebase 未定义符号【英文标题】:Firebase Undefined symbols 【发布时间】:2019-01-22 13:35:16 【问题描述】:

我正在通过cocoapodsfirebase 添加到我的ios 项目中。但是在执行之后

`pod install`

我收到架构 arm64 的未定义符号:错误:

完整的错误列表:

`Undefined symbols for architecture arm64:
  "___ubsan_handle_add_overflow", referenced from:
  _ReadRawVarInt32 in 
FirebaseMessaging(FIRMessagingCodedInputStream.o)
  -[FIRMessagingConnection willProcessProto:] in FirebaseMessaging(FIRMessagingConnection.o)
  -[FIRMessagingConnection willSendProto:] in FirebaseMessaging(FIRMessagingConnection.o)
  -[FIRMessagingDelayedMessageQueue queueMessage:] in FirebaseMessaging(FIRMessagingDelayedMessageQueue.o)
  -[FIRMessagingDataMessageManager handleExpirationForDataMessage:] in FirebaseMessaging(FIRMessagingDataMessageManager.o)
  +[FIRMessagingReceiver nextMessageID] in FirebaseMessaging(FIRMessagingReceiver.o)
  -[FIRMessagingRmqManager loadInitialOutgoingPersistentId] in FirebaseMessaging(FIRMessagingRmqManager.o)
  ...
  "___ubsan_handle_divrem_overflow", referenced from:
  _FIRMessagingGetFreeDiskSpaceInMB in 
FirebaseMessaging(FIRMessagingUtilities.o)
  "___ubsan_handle_float_cast_overflow", referenced from:
  -[FIRMessaging setupSyncMessageManager] in 
FirebaseMessaging(FIRMessaging.o)
  -[FIRMessagingDelayedMessageQueue calculateTimeoutInMillisWithDelayInSeconds:] in 
FirebaseMessaging(FIRMessagingDelayedMessageQueue.o)
  -[FIRMessagingClient retryConnectionImmediately:] in 
FirebaseMessaging(FIRMessagingClient.o)
  _FIRMessagingCurrentTimestampInSeconds in 
FirebaseMessaging(FIRMessagingUtilities.o)
  _FIRMessagingCurrentTimestampInMilliseconds in 
FirebaseMessaging(FIRMessagingUtilities.o)
  _FIRMessagingGetFreeDiskSpaceInMB in 
FirebaseMessaging(FIRMessagingUtilities.o)
  "___ubsan_handle_load_invalid_value", referenced from:
  -[FIRApp setDataCollectionDefaultEnabled:] in 
FirebaseCore(FIRApp.o)
  -[FIRApp isAppIDValid] in FirebaseCore(FIRApp.o)
  -[FIRApp alreadyOutputDataCollectionFlag] in 
FirebaseCore(FIRApp.o)
  -[FIRApp setAlreadyOutputDataCollectionFlag:] in 
FirebaseCore(FIRApp.o)
  -[FIRApp isDefaultApp] in FirebaseCore(FIRApp.o)
  +[FIRDependency dependencyWithProtocol:isRequired:] in 
FirebaseCore(FIRDependency.o)
  -[FIRDependency initWithProtocol:isRequired:] in 
FirebaseCore(FIRDependency.o)
  ...
  "___ubsan_handle_negate_overflow", referenced from:
  -[FIRMessagingConnection logMessage:messageType:isOut:] in 
FirebaseMessaging(FIRMessagingConnection.o)
  "___ubsan_handle_nonnull_arg", referenced from:
  +[FIRApp registerAsConfigurable:] in FirebaseCore(FIRApp.o)
  +[FIRApp readDataCollectionSwitchFromPlist] in 
FirebaseCore(FIRApp.o)
  +[FIRConfiguration sharedInstance] in 
FirebaseCore(FIRConfiguration.o)
  +[FIRAnalyticsConfiguration sharedInstance] in 
FirebaseCore(FIRAnalyticsConfiguration.o)
  +[FIRComponentContainer registerAsComponentRegistrant:] in 
FirebaseCore(FIRComponentContainer.o)
  _FIRLoggerInitializeASL in FirebaseCore(FIRLogger.o)
  +[FIRMessaging messaging] in FirebaseMessaging(FIRMessaging.o)
  ...
  "___ubsan_handle_pointer_overflow", referenced from:
  _ReadRawByte in FirebaseMessaging(FIRMessagingCodedInputStream.o)
  -[FIRMessagingSecureSocket performRead] in 
FirebaseMessaging(FIRMessagingSecureSocket.o)
  "___ubsan_handle_shift_out_of_bounds", referenced from:
  _ReadRawVarInt32 in 
FirebaseMessaging(FIRMessagingCodedInputStream.o)
  _LogicalRightShift32 in 
FirebaseMessaging(FIRMessagingSecureSocket.o)
  -[FIRMessagingClient nextRetryInterval] in 
FirebaseMessaging(FIRMessagingClient.o)
  "___ubsan_handle_sub_overflow", referenced from:
  +[FIRMessagingPendingTopicsList pruneTopicBatches:] in 
FirebaseMessaging(FIRMessagingPendingTopicsList.o)
  -[FIRMessagingConnection willProcessProto:] in 
FirebaseMessaging(FIRMessagingConnection.o)
  -[FIRMessagingDelayedMessageQueue scheduleTimeoutInMillis:] in 
FirebaseMessaging(FIRMessagingDelayedMessageQueue.o)
  -[FIRMessagingDataMessageManager sendDelayedMessages:] in 
FirebaseMessaging(FIRMessagingDataMessageManager.o)
  "___ubsan_handle_type_mismatch_v1", referenced from:
  -[FIRApp initInstanceWithName:options:] in FirebaseCore(FIRApp.o)
  -[FIRApp configureCore] in FirebaseCore(FIRApp.o)
  -[FIRApp options] in FirebaseCore(FIRApp.o)
  +[FIRApp registerAsConfigurable:] in FirebaseCore(FIRApp.o)
  -[FIRApp isAppIDValid] in FirebaseCore(FIRApp.o)
  -[FIRApp expectedBundleID] in FirebaseCore(FIRApp.o)
  +[FIRApp readDataCollectionSwitchFromPlist] in 
FirebaseCore(FIRApp.o)
  ...

ld:未找到架构 arm64 的符号 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)`

我已尝试清理项目、清除缓存并删除 pod 并重新安装。

platform :ios, '11.0'

使用_frameworks!

禁止所有 pod 的编译器警告(除非将 inhibitor_warnings 设置为 false)。

inhibit_all_warnings!

目标'通用查看器'做

pod 'VatomicSDK', :path => '../ios-vatoms-sdk', :inhibit_warnings => false # Locally reference our SDK (i.e. not pulled from Cocoapods)
pod 'Crashlytics'
pod 'Fabric'
pod 'FBSDKLoginKit'
pod 'Firebase/Core',            '~> 5.0'
pod 'AFNetworking',             '~> 2.0'    # CraftAR framework
pod 'libPhoneNumber-iOS'
pod 'Stripe',                   '~> 13.0'
pod 'NSAttributedString-DDhtml'             # HTML string parsing
pod 'PromiseKit',               '~> 4.0'
pod 'PureLayout'

pod 'UIAlertController+Show'
pod 'ReachabilitySwift'
pod 'DateToolsSwift'
pod 'SwiftQRCode'
pod 'GPUImage'                              # Camera motion detection
pod 'Cheers'                                # Confetti

# Required for the 3D face in VatomicSDK
# NOTE: Once the author has fixed the versioning issue in their repo, these should be removed.
# See: https://***.com/questions/22447062/how-do-i-create-a-cocoapods-podspec-that-has-a-dependency-that-exists-outside-of/22475228#22475228
pod 'GLTF',     :git => "https://github.com/warrenm/GLTFKit.git", :commit => "e1939408bcd6990f477541915d5652d20e0f9edd"
pod 'GLTFSCN',  :git => "https://github.com/warrenm/GLTFKit.git", :commit => "e1939408bcd6990f477541915d5652d20e0f9edd"

pod 'Permission/Notifications'
pod 'Permission/Bluetooth'
pod 'Permission/Contacts'
pod 'Permission/Location'
pod 'Permission/Camera'

# Unit tests
target 'GV Unit Tests' do
end

# Developer Signed distribution target
# target 'Generic Viewer (Developer Signed)' do
# end

# Run code after project has been set up
post_install do |installer|

    # Some pods have not yet been updated to Swift 4.
    # As a temporary workaround, set their build version to Swift 3.2.
    myTargets = ['SwiftQRCode', 'Permission']
    installer.pods_project.targets.each do |target|
        if myTargets.include? target.name
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '3.2'
            end
        end
    end

end

结束

【问题讨论】:

按以下确切顺序放置以下 pod:pod 'Firebase' 然后 pod 'Firebase/Messaging' ` @om-ha 现在尝试一下 @om-ha 没有变化,同样的错误 尝试clearing derived data或clearing pod cache最后可能是链接器错误1或2 我也会尝试pod 'Firebase' 而不是pod 'Firebase/Core'。最后确保您已包含 Firebase 文档中指定的所有必需框架。因为这可能是链接器错误。 【参考方案1】:

我设法解决了这个问题:

1) 编辑方案

2) 确保 Undefined Behavior Sanitiser 已关闭(如果它是灰色的,您必须通过右键单击项目文件/Show Package Contents/xcsharedata/xcschemes 手动编辑它)

3) 移除 pod - pod deintegrate && pod cache clean --all

4) 安装 pod - pod install

【讨论】:

以上是关于Firebase 未定义符号的主要内容,如果未能解决你的问题,请参考以下文章

将 Firebase 与 Google Toolbox for Mac 一起使用时出现未定义符号 Xcode 错误

架构 x86_64 颤动的未定义符号

架构 armv7 的未定义符号:“_OBJC_CLASS_$_FIRApp”

“未捕获的 ReferenceError:未定义 firebase”。如何在 Chrome 中定义 firebase 并超越黑屏?

未捕获的 ReferenceError:Flutter 中未定义 firebase

未定义名称“firebase”颤振