Firebase 崩溃.. iOS Swift
Posted
技术标签:
【中文标题】Firebase 崩溃.. iOS Swift【英文标题】:Firebase Crash.. iOS Swift 【发布时间】:2016-06-03 23:57:21 【问题描述】:由于 cocoapods 中的某些原因,我不得不手动将框架放入 Firebase ios 应用程序中。
我收到一个崩溃错误提示
2016-06-04 00:48:51.356 NewFirebase[74218:11918327] Configuring the default app.
2016-06-04 00:48:51.401 NewFirebase[74218:11918425] +[NSData gtm_dataByGzippingData:]: unrecognized selector sent to class 0x10bdd8110
2016-06-04 00:48:51.403 NewFirebase[74218:] <FIRAnalytics/INFO> Firebase Analytics v.3200000 started
2016-06-04 00:48:51.404 NewFirebase[74218:11918425] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSData gtm_dataByGzipping
我与firebase相关的唯一一行是
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
// Override point for customization after application launch.
FIRApp.configure()
FBSDKApplicationDelegate.sharedInstance().application(application,
didFinishLaunchingWithOptions: launchOptions)
return true
其他与 facebook 登录有关,我将使用 firebase
这些是其中的框架
这是链接器部分在构建设置中的样子
如果您需要更多代码,请随意
如果我摆脱 FIRApp.configure()
一切正常,应该是..
【问题讨论】:
您是否从 console.firebase.google.com 下载并添加了 GoogleService-Info 属性列表? 嘿,你做得比我好:101 个链接器错误。我按照 README 中的说明进行操作,上面说它们适用于 Xcode 7。 我遇到了同样的问题。 Google 的文档似乎不完整。我选择不使用 CocoaPods,正在导入所有库,并设置了 -Objc“其他链接器标志”。仍然崩溃。 【参考方案1】:你需要添加这些库
libc++.tbd libsqlite3.tbd AddressBook.framework将二进制文件与库链接。
转到目标 -> 构建阶段
【讨论】:
我还必须添加libz.tbd
除了上面的。
这为我修复了构建。怎么没在设置说明里?一个非常神秘的错误信息。【参考方案2】:
在 Other Linker Flags 中添加两个参数
$(inherited)
-ObjC
【讨论】:
Getting Started Guide
链接到操作使用的内容,framework SDK
的自述文件说仅使用 -ObjC
。
查看下面的答案。,,,,我已经成功地使用 CocoaPods 创建了一个 Firebase 应用程序,但是遵循框架设置对我来说不起作用。 Xcode 7.2.1/iOS 9.2/Swift 2.1.1/OSX 10.10.5
【参考方案3】:
我在 OS X 10.11.5 上使用面向 iOS 9.3 的 Xcode 7.3.1。
我遇到了与上述“未定义符号”问题完全相同的问题。
我首先清空了“其他链接器标志”中的所有内容,然后将 $(OTHER_LDFLAGS) 和 -ObjC 作为 2 个单独的项目添加(双击时使用 + 按钮)。
我做的另一件事是删除给我带来问题的框架 - GoogleUtilities 和 FirebaseAnalytics。
然后我使用“将文件添加到项目”选项一次将它们添加回来,并确保它们针对我的 iOS 应用程序。
在那之后构建成功并且广告出现了。
【讨论】:
谢谢,也解决了我的问题!我添加了 3 行 $(inherited) $(OTHER_LDFLAGS) -ObjC【参考方案4】:我只是为此浪费了几个小时 - 自述文件和文档真的很差
您还需要包含 GoogleToolboxForMac.framework 我错过了这个,因为我认为它适用于 mac 应用程序,但添加它可以解决问题。
【讨论】:
你拯救了我的一天,我也有同样的想法,这解决了它 非常感谢您的回答!【参考方案5】:回答上面的评论:
编辑:这是我的Build Settings
的样子:
Firebase目录下的README.md表示将Firebase.h
文件拖入项目中,以及module.modulemap
文件并将module.modulemap文件的路径添加到User Header Search Paths
中:
Firebase 目录中的 README.md 表示此处仅输入 -ObjC
:
这是我的Project Navigator
的样子:
Ld /Users/7stud/Library/Developer/Xcode/DerivedData/FirebaseApplicationExample-ewixbbawksqkuaaqeeobeaexeirc/Build/Products/Debug-iphonesimulator/FirebaseApplicationExample.app/FirebaseApplicationExample normal x86_64
cd /Users/7stud/xcode_projects/iOS/FirebaseApplicationExample
export IPHONEOS_DEPLOYMENT_TARGET=9.2
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk -L/Users/7stud/Library/Developer/Xcode/DerivedData/FirebaseApplicationExample-ewixbbawksqkuaaqeeobeaexeirc/Build/Products/Debug-iphonesimulator -F/Users/7stud/Library/Developer/Xcode/DerivedData/FirebaseApplicationExample-ewixbbawksqkuaaqeeobeaexeirc/Build/Products/Debug-iphonesimulator -F/Users/7stud/xcode_projects/iOS/FirebaseApplicationExample/FirebaseApplicationExample -filelist /Users/7stud/Library/Developer/Xcode/DerivedData/FirebaseApplicationExample-ewixbbawksqkuaaqeeobeaexeirc/Build/Intermediates/FirebaseApplicationExample.build/Debug-iphonesimulator/FirebaseApplicationExample.build/Objects-normal/x86_64/FirebaseApplicationExample.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=9.2 -Xlinker -objc_abi_version -Xlinker 2 -ObjC -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/7stud/Library/Developer/Xcode/DerivedData/FirebaseApplicationExample-ewixbbawksqkuaaqeeobeaexeirc/Build/Intermediates/FirebaseApplicationExample.build/Debug-iphonesimulator/FirebaseApplicationExample.build/Objects-normal/x86_64/FirebaseApplicationExample.swiftmodule -framework FirebaseDatabase -framework GoogleInterchangeUtilities -framework FirebaseAnalytics -framework GoogleSymbolUtilities -framework GoogleUtilities -framework FirebaseInstanceID -Xlinker -dependency_info -Xlinker /Users/7stud/Library/Developer/Xcode/DerivedData/FirebaseApplicationExample-ewixbbawksqkuaaqeeobeaexeirc/Build/Intermediates/FirebaseApplicationExample.build/Debug-iphonesimulator/FirebaseApplicationExample.build/Objects-normal/x86_64/FirebaseApplicationExample_dependency_info.dat -o /Users/7stud/Library/Developer/Xcode/DerivedData/FirebaseApplicationExample-ewixbbawksqkuaaqeeobeaexeirc/Build/Products/Debug-iphonesimulator/FirebaseApplicationExample.app/FirebaseApplicationExample
Undefined symbols for architecture x86_64:
"_ABAddressBookAddRecord", referenced from:
-[GSDK_GTMABAddressBook addRecord:] in GoogleUtilities(GTMABAddressBook.o)
"_ABAddressBookCopyArrayOfAllGroups", referenced from:
-[GSDK_GTMABAddressBook groups] in GoogleUtilities(GTMABAddressBook.o)
"_ABAddressBookCopyArrayOfAllPeople", referenced from:
-[GSDK_GTMABAddressBook people] in GoogleUtilities(GTMABAddressBook.o)
"_ABAddressBookCopyLocalizedLabel", referenced from:
+[GSDK_GTMABAddressBook localizedLabel:] in GoogleUtilities(GTMABAddressBook.o)
"_ABAddressBookCopyPeopleWithName", referenced from:
-[GSDK_GTMABAddressBook peopleWithCompositeNameWithPrefix:] in GoogleUtilities(GTMABAddressBook.o)
"_ABAddressBookCreateWithOptions", referenced from:
-[GSDK_GTMABAddressBook init] in GoogleUtilities(GTMABAddressBook.o)
"_ABAddressBookGetGroupWithRecordID", referenced from:
-[GSDK_GTMABAddressBook groupForId:] in GoogleUtilities(GTMABAddressBook.o)
"_ABAddressBookGetPersonWithRecordID", referenced from:
-[GSDK_GTMABAddressBook personForId:] in GoogleUtilities(GTMABAddressBook.o)
"_ABAddressBookHasUnsavedChanges", referenced from:
-[GSDK_GTMABAddressBook hasUnsavedChanges] in GoogleUtilities(GTMABAddressBook.o)
"_ABAddressBookRemoveRecord", referenced from:
-[GSDK_GTMABAddressBook removeRecord:] in GoogleUtilities(GTMABAddressBook.o)
"_ABAddressBookSave", referenced from:
-[GSDK_GTMABAddressBook save] in GoogleUtilities(GTMABAddressBook.o)
"_ABGroupAddMember", referenced from:
-[GSDK_GTMABGroup addMember:] in GoogleUtilities(GTMABAddressBook.o)
"_ABGroupCopyArrayOfAllMembers", referenced from:
-[GSDK_GTMABGroup members] in GoogleUtilities(GTMABAddressBook.o)
"_ABGroupCreate", referenced from:
-[GSDK_GTMABGroup init] in GoogleUtilities(GTMABAddressBook.o)
"_ABGroupRemoveMember", referenced from:
-[GSDK_GTMABGroup removeMember:] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueAddValueAndLabel", referenced from:
-[GSDK_GTMABMutableMultiValue addValue:withLabel:] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueCopyLabelAtIndex", referenced from:
-[GSDK_GTMABMultiValue labelAtIndex:] in GoogleUtilities(GTMABAddressBook.o)
-[GSDK_GTMABMultiValueEnumerator nextObject] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueCopyValueAtIndex", referenced from:
-[GSDK_GTMABMultiValue valueAtIndex:] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueCreateMutable", referenced from:
-[GSDK_GTMABMutableMultiValue initWithPropertyType:] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueCreateMutableCopy", referenced from:
-[GSDK_GTMABMutableMultiValue initWithMultiValue:] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueGetCount", referenced from:
-[GSDK_GTMABMultiValue count] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueGetIdentifierAtIndex", referenced from:
-[GSDK_GTMABMultiValue identifierAtIndex:] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueGetIndexForIdentifier", referenced from:
-[GSDK_GTMABMultiValue indexForIdentifier:] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueGetPropertyType", referenced from:
-[GSDK_GTMABMultiValue propertyType] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueInsertValueAndLabelAtIndex", referenced from:
-[GSDK_GTMABMutableMultiValue insertValue:withLabel:atIndex:] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueRemoveValueAndLabelAtIndex", referenced from:
-[GSDK_GTMABMutableMultiValue removeValueAndLabelAtIndex:] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueReplaceLabelAtIndex", referenced from:
-[GSDK_GTMABMutableMultiValue replaceLabelAtIndex:withLabel:] in GoogleUtilities(GTMABAddressBook.o)
"_ABMultiValueReplaceValueAtIndex", referenced from:
-[GSDK_GTMABMutableMultiValue replaceValueAtIndex:withValue:] in GoogleUtilities(GTMABAddressBook.o)
"_ABPersonCopyImageData", referenced from:
-[GSDK_GTMABPerson imageData] in GoogleUtilities(GTMABAddressBook.o)
"_ABPersonCopyLocalizedPropertyName", referenced from:
+[GSDK_GTMABPerson localizedPropertyName:] in GoogleUtilities(GTMABAddressBook.o)
"_ABPersonCreate", referenced from:
-[GSDK_GTMABPerson init] in GoogleUtilities(GTMABAddressBook.o)
"_ABPersonGetCompositeNameFormat", referenced from:
+[GSDK_GTMABPerson compositeNameFormat] in GoogleUtilities(GTMABAddressBook.o)
"_ABPersonGetTypeOfProperty", referenced from:
+[GSDK_GTMABPerson typeOfProperty:] in GoogleUtilities(GTMABAddressBook.o)
"_ABPersonRemoveImageData", referenced from:
-[GSDK_GTMABPerson setImageData:] in GoogleUtilities(GTMABAddressBook.o)
"_ABPersonSetImageData", referenced from:
-[GSDK_GTMABPerson setImageData:] in GoogleUtilities(GTMABAddressBook.o)
"_ABRecordCopyCompositeName", referenced from:
-[GSDK_GTMABPerson compositeName] in GoogleUtilities(GTMABAddressBook.o)
-[GSDK_GTMABGroup compositeName] in GoogleUtilities(GTMABAddressBook.o)
"_ABRecordCopyValue", referenced from:
-[GSDK_GTMABRecord valueForProperty:] in GoogleUtilities(GTMABAddressBook.o)
"_ABRecordGetRecordID", referenced from:
-[GSDK_GTMABRecord recordID] in GoogleUtilities(GTMABAddressBook.o)
"_ABRecordRemoveValue", referenced from:
-[GSDK_GTMABRecord removeValueForProperty:] in GoogleUtilities(GTMABAddressBook.o)
"_ABRecordSetValue", referenced from:
-[GSDK_GTMABRecord setValue:forProperty:] in GoogleUtilities(GTMABAddressBook.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(char const*) const", referenced from:
leveldb::VersionSet::Recover() in FirebaseDatabase(version_set.o)
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
void std::__1::vector<std::__1::pair<int, leveldb::FileMetaData>, std::__1::allocator<std::__1::pair<int, leveldb::FileMetaData> > >::__push_back_slow_path<std::__1::pair<int, leveldb::FileMetaData> const>(std::__1::pair<int, leveldb::FileMetaData> const&) in FirebaseDatabase(db_impl.o)
void std::__1::vector<unsigned long long, std::__1::allocator<unsigned long long> >::__push_back_slow_path<unsigned long long const>(unsigned long long const&) in FirebaseDatabase(db_impl.o)
void std::__1::vector<leveldb::DBImpl::CompactionState::Output, std::__1::allocator<leveldb::DBImpl::CompactionState::Output> >::__push_back_slow_path<leveldb::DBImpl::CompactionState::Output const>(leveldb::DBImpl::CompactionState::Output const&) in FirebaseDatabase(db_impl.o)
void std::__1::vector<leveldb::Iterator*, std::__1::allocator<leveldb::Iterator*> >::__push_back_slow_path<leveldb::Iterator* const>(leveldb::Iterator* const&) in FirebaseDatabase(db_impl.o)
...
...
"_utf8_nextCharSafeBody", referenced from:
-[FSRWebSocket _innerPumpScanner] in FirebaseDatabase(FSRWebSocket.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Showing first 200 notices only
【讨论】:
【参考方案6】:添加此链接器标志为我解决了这个问题。我首先尝试使用 CocoaPods,但无法让它导入任何更具体的 Firebase 模块。添加框架直接起作用,但前提是添加了 -ObjC 链接器标志。
【讨论】:
【参考方案7】:我只是从另一个项目中拖动代码文件和框架,遇到了这个问题。 在构建阶段添加所有框架后,在“其他链接器标志”中添加 -ObjC 解决了该问题。
【讨论】:
【参考方案8】:我通过从我的项目中删除 FirebaseNanoPB 和 FirebaseCoreDiagnostics 框架解决了这个问题。
【讨论】:
我已经为这个问题苦苦挣扎了 6 周。我已经尝试了几十个建议:我当然设置了 ObjC 标志(就像每个人在无数 *** 线程中建议一百万次一样),我添加和删除了各种框架,从头开始重新创建我的项目,以防我有一个损坏的工作区,移动远离 pod 并手动安装我所有的框架。事实证明,除了 Analytics 之外,我只需要删除这两个框架(因为它依赖于它们)。谢谢你的建议。以上是关于Firebase 崩溃.. iOS Swift的主要内容,如果未能解决你的问题,请参考以下文章
Firebase iOS SDK 崩溃与 FIRInstallations validateAppOptions:appName