ios 架构 x86_64 的 Firebase 未定义符号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42292090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Firebase Undefined symbols for architecture x86_64
提问by gdev
I am using firebase as part of a project I am working on in iOS, and I just stumbled upon the following linking error when I try to compile my code against an iPhone 6 or 7 simulator for testing.
我正在使用 firebase 作为我在 iOS 中工作的项目的一部分,当我尝试针对 iPhone 6 或 7 模拟器编译代码进行测试时,我偶然发现了以下链接错误。
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GTMSessionUploadFetcher", referenced from:
objc-class-ref in FirebaseStorage(FIRStorageUploadTask_d5061b1e2b5f1bb249816cc5fc42ff62.o)
"_OBJC_CLASS_$_GTMLogger", referenced from:
objc-class-ref in FirebaseMessaging(GIPReachability_ae5504e4a6a28a1d8997c6f38e8bff8b.o)
"_kGTMSessionUploadFetcherStandardChunkSize", referenced from:
-[FIRStorageUploadTask enqueue] in FirebaseStorage(FIRStorageUploadTask_d5061b1e2b5f1bb249816cc5fc42ff62.o)
"_GTMFetcherStandardUserAgentString", referenced from:
-[FIRAuthBackendRPCIssuerImplementation init] in FirebaseAuth(FIRAuthBackend_ea73237c278bd1b78e1c76db2a16775a.o)
"_OBJC_CLASS_$_GTMSessionFetcher", referenced from:
objc-class-ref in FirebaseStorage(FIRStorageDownloadTask_c390366e83519f6636ca985ecb70e5d0.o)
objc-class-ref in FirebaseStorage(FIRStorage_691ea9ac7cb4d224d37df2ff8a911989.o)
"_OBJC_CLASS_$_GTMSessionFetcherService", referenced from:
objc-class-ref in FirebaseAuth(FIRAuthBackend_ea73237c278bd1b78e1c76db2a16775a.o)
objc-class-ref in FirebaseStorage(FIRStorage_691ea9ac7cb4d224d37df2ff8a911989.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am using Xcode 8.2.1, swift 3.0, and I also have the following Pod file in my project
我正在使用 Xcode 8.2.1、swift 3.0,并且我的项目中还有以下 Pod 文件
pod 'Braintree'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Core'
pod 'Firebase/Storage'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
pod 'GeoFire', :git=>'https://github.com/firebase/geofire-objc.git'
pod 'ObjectMapper', '~> 2.2'
I have done a pod update in case something was out of date, but no luck. The code compiles and runs fine when I use an iPhone 4 or 5 simulator.
我已经做了一个 pod 更新,以防万一过时,但没有运气。当我使用 iPhone 4 或 5 模拟器时,代码编译并运行良好。
Edit:
编辑:
I have set Build Active architectures to No, in valid architectures I have listed arm64, armv7, armv7s and now Objectmapper is failing even though import ObjectMapper
is declared in the file
我已将 Build Active architectures 设置为 No,在有效的体系结构中我列出了 arm64、armv7、armv7s,现在即使import ObjectMapper
在文件中声明了Objectmapper 也失败了
Use of undeclared type 'Mappable'
Any help would be greatly appreciated! Thank you in advance.
任何帮助将不胜感激!先感谢您。
George.
乔治。
采纳答案by gdev
It seems to be a glitch with derived data. I quitted out of Xcode, I removed all Derived Data in /Users/USER_NAME/Library/Developer/Xcode/PROJECT_NAME
派生数据似乎有问题。我退出了 Xcode,我删除了所有派生数据/Users/USER_NAME/Library/Developer/Xcode/PROJECT_NAME
Restarted Xcode, compiled and all works as expected, no need to change anything in Active Architecture Only
or anything.
重新启动 Xcode,编译并按预期工作,无需更改任何内容Active Architecture Only
或任何内容。
回答by Quan Nguyen
For me I just installed Firebase framework to Xcode, not using CocoaPods due to other unsolvable issues. After build there is similar errors like above with "symbol(s) not found for architecture x86_64". (maybe because I am working with Xcode on VMWare)
对我来说,我只是将 Firebase 框架安装到 Xcode,由于其他无法解决的问题,我没有使用 CocoaPods。构建后有类似上面的错误,“没有找到架构 x86_64 的符号”。(也许是因为我在 VMWare 上使用 Xcode)
Then I have to manually go to General - Linked Frameworks and Librariesand add:
然后我必须手动转到General - Linked Frameworks and Libraries并添加:
libsqlite3.tbd, libz.tbd, libc++.tbd
libsqlite3.tbd、libz.tbd、libc++.tbd
for the project to work.
使项目正常工作。
回答by coyer
Just discovered a similar problem and got it solved by clearing Pod-Cache.
刚刚发现了一个类似的问题,并通过清除 Pod-Cache 解决了它。
Clear CocoaPods Cache
清除 CocoaPods 缓存
pod deintegrate && pod cache clean --all
pod deintegrate && pod cache clean --all
Re-Install Pods
重新安装 Pod
pod install
吊舱安装
回答by Kilo Loco
I tried the "clearing Cocoapods cache" and the "removing derived data" solutions but that didn't work. What worked for me was a step I found in the Carthage setup (I'm still using Cocoapods)
我尝试了“清除 Cocoapods 缓存”和“删除派生数据”解决方案,但没有奏效。对我有用的是我在 Carthage 设置中找到的一个步骤(我仍在使用 Cocoapods)
Add
$(OTHER_LDFLAGS) -ObjC
flag to "Other Linker Flags" in "Build Settings".
将
$(OTHER_LDFLAGS) -ObjC
标志添加到“构建设置”中的“其他链接器标志”。
You can see the step here: https://github.com/firebase/firebase-ios-sdk/blob/master/Carthage.md
你可以在这里看到这个步骤:https: //github.com/firebase/firebase-ios-sdk/blob/master/Carthage.md
My Info
我的信息
Installation: Cocoapods | SDK: FirebaseAnalytics (6.1.2) | IDE: Xcode 11.0 | macOS: Mojave 10.14.5 Beta | Language: Swift 4.2 | Platform Target: iOS 11.0+
安装:Cocoapods | SDK:FirebaseAnalytics (6.1.2) | IDE:Xcode 11.0 | macOS:莫哈韦沙漠 10.14.5 测试版 | 语言:Swift 4.2 | 平台目标:iOS 11.0+
回答by Leemur
Also had this problem after installing pods for Firebase, using CocoaPods as explained in the Firebase site:
使用 CocoaPods 为 Firebase 安装 pod 后也遇到了这个问题,如 Firebase 站点中所述:
https://firebase.google.com/docs/ios/setup?hl=es-419#prerequisites
https://firebase.google.com/docs/ios/setup?hl=es-419#prerequisites
pod 'Firebase/Analytics' pod 'Firebase/Auth'
吊舱“Firebase/Analytics”吊舱“Firebase/Auth”
During the installation of the pods I received a warning telling that:
在安装 Pod 的过程中,我收到了一条警告:
[!] The target `myTarget [Debug]` overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig'.
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The target `myTarget [Release]` overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig'.
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
When I compiled I got the error for several files:
当我编译时,我收到了几个文件的错误:
Undefined symbols for architecture x86_64:
I tried the solution of the following answer before the one in this answer, and it worked as a charm:
我在本答案中的答案之前尝试了以下答案的解决方案,它很有魅力:
The target ... overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig
目标 ... 覆盖 `Pods/Pods.xcconfig 中定义的 `OTHER_LDFLAGS` 构建设置
Basically the solution was (as explained by @Ankish Jain):
基本上解决方案是(如@Ankish Jain 所解释的):
Go to your TargetBuild Settings -> Other linker flags -> double click -> + button. Add $(inherited) to a new line.
转到您的目标构建设置 -> 其他链接器标志 -> 双击 -> + 按钮。将 $(inherited) 添加到新行。
After that I compiled succesfully, and new flag where added automatically to the Build Settings.
之后我编译成功,新标志自动添加到构建设置中。
回答by Augie
I tried the solutions in this question, and nothing worked. Also found other threads in SO and GitHub issues. Nothing helped. I am using Xcode 9.2, Swift 4, latest version of cocoa pods. This worked for me...
我尝试了这个问题中的解决方案,但没有任何效果。还在 SO 和 GitHub 问题中找到了其他线程。没有任何帮助。我正在使用 Xcode 9.2、Swift 4、最新版本的可可豆荚。这对我有用...
First, my podfile only contains one firebase pod since I am only using Analytics at this point, however solution approach should be the same if you're using more.
pod 'Firebase/Core'
首先,我的 podfile 只包含一个 firebase pod,因为此时我只使用 Analytics,但是如果您使用更多,解决方法应该是相同的。
吊舱“Firebase/核心”
Second, like documentation states, make sure -ObjC is added to your Other Linker Flags. I did this both at project and target level build settings. They were different.
其次,像文档说明一样,确保将 -ObjC 添加到您的其他链接器标志中。我在项目和目标级别的构建设置中都这样做了。他们是不同的。
Third and most important, at Project level build settings, Other Linker Flags, add the following
第三个也是最重要的,在项目级别的构建设置,其他链接器标志,添加以下内容
-framework
-框架
"FirebaseCore"
“火力地基核心”
-framework
-框架
"FirebaseAnalytics"
“Firebase 分析”
-framework
-框架
"FirebaseInstanceID"
“FirebaseInstanceID”
-framework
-框架
"FirebaseNanoPB"
“FirebaseNanoPB”
-framework
-框架
"FirebaseCoreDiagnostics"
“FirebaseCoreDiagnostics”
-framework
-框架
"nanopb"
“纳米”
回答by COSMO BAKER
Had the same problem, and for me the issue was that I had imported the FirebaseMessaging framework manually, by downloading the entire Firebase SDK and then manually importing the Messaging framework into the project (I didn't use Cocoapods or Carthage). I didn't import the other framework in the same folder, "Protobuf.framework". Once adding Protobuf and making sure the target memberships included my project target, it worked.
遇到了同样的问题,对我来说,问题是我手动导入了 FirebaseMessaging 框架,方法是下载整个 Firebase SDK,然后手动将 Messaging 框架导入到项目中(我没有使用 Cocoapods 或 Carthage)。我没有在同一个文件夹“Protobuf.framework”中导入另一个框架。添加 Protobuf 并确保目标成员资格包括我的项目目标后,它就起作用了。
回答by Mark Kazakov
Also had this issue...
Added $(inherited)
to other linker flags in build settings and everything works fine now
也有这个问题......
添加 $(inherited)
到构建设置中的其他链接器标志,现在一切正常
回答by Ryan
I encountered this issue before, It looks like you need to:
我之前遇到过这个问题,看来您需要:
rm -rf ios/Podfile ios/Podfile.lock ios/Pods ios/Runner.xcworkspace
rm -rf ios/Podfile ios/Podfile.lock ios/Pods ios/Runner.xcworkspace
and then run
flutter run
然后运行
flutter run
Source: https://github.com/flutter/flutter/issues/41900
来源:https: //github.com/flutter/flutter/issues/41900
UPDATE:
run this fix the issue too:
rm -f ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
更新:也运行此修复问题:
rm -f ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
回答by G Wayne
In my case, for using only Firebase Auth and Firebase Firestore, installing with Cocoapods, all I had to do was click the +
sign for both Debug
and Release
sections under Other Linker Flags
in Build Settings. The $(inherited)
flag was added automatically. Built just fine after that!
就我而言,为了仅使用 Firebase Auth 和 Firebase Firestore,使用 Cocoapods 进行安装,我所要做的就是单击Build Settings下的和部分的+
标志。该标志是自动添加的。在那之后建造得很好!Debug
Release
Other Linker Flags
$(inherited)