Closed retrobrain closed 7 years ago
The stack overflow suggestion is correct you need to downgrade the pods (i.e all Firebase pods) to 3.17.0.
Regarding the exception, do you have the complete stack trace you could share?
On Fri, May 26, 2017 at 9:25 AM, Artem Chystikov notifications@github.com wrote:
Operating system: macos Operating system version: 10.12.3 CocoaPods version: 1.2.1 Firebase C++ SDK version: 3.1.2
Podfile contents: platform :ios, '8.0' target 'firebaseTest-mobile' do use_frameworks! pod 'Firebase/Core' pod 'Firebase/AdMob' pod 'Firebase/Auth' pod 'GoogleSignIn' pod 'Firebase/Database' pod 'Firebase/RemoteConfig' pod 'Firebase/Storage' end
I'm trying to add Firebase C++ SDK to my cocos2d app. The app builds and runs successfully but when I add this piece of code: std::string token = UserDefault::getInstance()->getStringForKey("GID"); firebase::auth::Credential credential = firebase::auth:: GoogleAuthProvider::GetCredential(token.c_str(), nullptr);
a linker error appears: Undefined symbols for architecture armv7: "_OBJCCLASS$_FIREmailPasswordAuthProvider", referenced from: objc-class-ref in firebase_auth(credentialios de0c3e1fa34e9a30835a63e195323a0f.o) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've added the $(inherited) flag to the Framework Search path, Other Linker Flags and Preprocessor Macros. The other suggestion from StackOverflow was to downgrade the pods version to 3.17.0. I tried it and this fixed the linker error but the app crashed in runtime on the same line of code and an exception was thrown '*** +[NSString stringWithUTF8String:]: NULL cString'
I also tried running the quickstart-cpp-master and the cocos2dx-cpp-sample but always got the same linker error.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/firebase/cocos2dx-cpp-sample/issues/8, or mute the thread https://github.com/notifications/unsubscribe-auth/AFw1RHKAANIbapv8a8f9oB1dTVsOZN1Hks5r9vz0gaJpZM4NnzQt .
@stewartmiles , yes sure I can.
thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x1d090ad4 libsystem_kernel.dylib__pthread_kill + 8 frame #1: 0x1d14718a libsystem_pthread.dylib
pthread_kill + 62
frame #2: 0x1d024338 libsystem_c.dylibabort + 108 frame #3: 0x1cb28568 libc++abi.dylib
abort_message + 108
frame #4: 0x1cb4250e libc++abi.dylibdefault_terminate_handler() + 270 frame #5: 0x1cb4b304 libobjc.A.dylib
_objc_terminate() + 192
frame #6: 0x1cb3f93e libc++abi.dylibstd::__terminate(void (*)()) + 78 frame #7: 0x1cb3f442 libc++abi.dylib
__cxa_rethrow + 90
frame #8: 0x1cb4b1ba libobjc.A.dylibobjc_exception_rethrow + 42 frame #9: 0x1d7f15a0 CoreFoundation
CFRunLoopRunSpecific + 596
frame #10: 0x1d7f1340 CoreFoundationCFRunLoopRunInMode + 104 frame #11: 0x1efc8bfc GraphicsServices
GSEventRunModal + 156
frame #12: 0x229ffe26 UIKit-[UIApplication _run] + 574 frame #13: 0x229fa550 UIKit
UIApplicationMain + 150
main(argc=1, argv=0x00eb19b8) at main.m:6 frame #15: 0x1cfbb50a libdyld.dylib
start + 2thread #4
frame #0: 0x1d091744 libsystem_kernel.dylib__workq_kernreturn + 8 frame #1: 0x1d1437fc libsystem_pthread.dylib
_pthread_wqthread + 854
frame #2: 0x1d143490 libsystem_pthread.dylib`start_wqthread + 8
thread #7, name = 'gputools.smt_poll.0x16e70310'
frame #0: 0x1d090e84 libsystem_kernel.dylib__semwait_signal + 24 frame #1: 0x1cfe334a libsystem_c.dylib
nanosleep + 168
frame #2: 0x1cfe329e libsystem_c.dylibusleep + 50 frame #3: 0x012af5ea GPUToolsCore
smt_poll_thread_entry(void*) + 126
frame #4: 0x1d145a26 libsystem_pthread.dylib_pthread_body + 216 frame #5: 0x1d14594c libsystem_pthread.dylib
_pthread_start + 234
frame #6: 0x1d14349c libsystem_pthread.dylib`thread_start + 8
thread #8, name = 'gputools.smt_poll.0x16d79130'
frame #0: 0x1d090e84 libsystem_kernel.dylib__semwait_signal + 24 frame #1: 0x1cfe334a libsystem_c.dylib
nanosleep + 168
frame #2: 0x1cfe329e libsystem_c.dylibusleep + 50 frame #3: 0x012af5ea GPUToolsCore
smt_poll_thread_entry(void*) + 126
frame #4: 0x1d145a26 libsystem_pthread.dylib_pthread_body + 216 frame #5: 0x1d14594c libsystem_pthread.dylib
_pthread_start + 234
frame #6: 0x1d14349c libsystem_pthread.dylib`thread_start + 8
thread #9, name = 'com.apple.uikit.eventfetch-thread'
frame #0: 0x1d07b84c libsystem_kernel.dylibmach_msg_trap + 20 frame #1: 0x1d07b63e libsystem_kernel.dylib
mach_msg + 42
frame #2: 0x1d8a42f8 CoreFoundation__CFRunLoopServiceMachPort + 136 frame #3: 0x1d8a25f6 CoreFoundation
CFRunLoopRun + 1014
frame #4: 0x1d7f1532 CoreFoundationCFRunLoopRunSpecific + 486 frame #5: 0x1d7f1340 CoreFoundation
CFRunLoopRunInMode + 104
frame #6: 0x1e14b88a Foundation-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 260 frame #7: 0x1e16a630 Foundation
-[NSRunLoop(NSRunLoop) runUntilDate:] + 86
frame #8: 0x233062b2 UIKit-[UIEventFetcher threadMain] + 128 frame #9: 0x1e234b10 Foundation
NSThreadstart + 1160
frame #10: 0x1d145a26 libsystem_pthread.dylib_pthread_body + 216 frame #11: 0x1d14594c libsystem_pthread.dylib
_pthread_start + 234
frame #12: 0x1d14349c libsystem_pthread.dylib`thread_start + 8
thread #12, name = 'com.apple.NSURLConnectionLoader'
frame #0: 0x1d07b84c libsystem_kernel.dylibmach_msg_trap + 20 frame #1: 0x1d07b63e libsystem_kernel.dylib
mach_msg + 42
frame #2: 0x1d8a42f8 CoreFoundation__CFRunLoopServiceMachPort + 136 frame #3: 0x1d8a25f6 CoreFoundation
__CFRunLoopRun + 1014
frame #4: 0x1d7f1532 CoreFoundationCFRunLoopRunSpecific + 486 frame #5: 0x1d7f1340 CoreFoundation
CFRunLoopRunInMode + 104
frame #6: 0x1decc488 CFNetwork+[NSURLConnection(Loader) _resourceLoadLoop:] + 416 frame #7: 0x1e234b10 Foundation
NSThreadstart__ + 1160
frame #8: 0x1d145a26 libsystem_pthread.dylib_pthread_body + 216 frame #9: 0x1d14594c libsystem_pthread.dylib
_pthread_start + 234
frame #10: 0x1d14349c libsystem_pthread.dylib`thread_start + 8
thread #14, name = 'AVAudioSession Notify Thread'
frame #0: 0x1d07b84c libsystem_kernel.dylibmach_msg_trap + 20 frame #1: 0x1d07b63e libsystem_kernel.dylib
mach_msg + 42
frame #2: 0x1d8a42f8 CoreFoundation__CFRunLoopServiceMachPort + 136 frame #3: 0x1d8a25f6 CoreFoundation
__CFRunLoopRun + 1014
frame #4: 0x1d7f1532 CoreFoundationCFRunLoopRunSpecific + 486 frame #5: 0x1d7f1340 CoreFoundation
CFRunLoopRunInMode + 104
frame #6: 0x3406dd36 AVFAudioGenericRunLoopThread::Entry(void*) + 142 frame #7: 0x340965fa AVFAudio
CAPThread::Entry(CAPThread*) + 154
frame #8: 0x1d145a26 libsystem_pthread.dylib_pthread_body + 216 frame #9: 0x1d14594c libsystem_pthread.dylib
_pthread_start + 234
frame #10: 0x1d14349c libsystem_pthread.dylib`thread_start + 8
thread #19
frame #0: 0x1d091744 libsystem_kernel.dylib__workq_kernreturn + 8 frame #1: 0x1d1439a0 libsystem_pthread.dylib
_pthread_wqthread + 1274
frame #2: 0x1d143490 libsystem_pthread.dylib`start_wqthread + 8
thread #20
frame #0: 0x1d090810 libsystem_kernel.dylib__psynch_cvwait + 24 frame #1: 0x1d144d2e libsystem_pthread.dylib
_pthread_cond_wait + 542
frame #2: 0x1d1460be libsystem_pthread.dylibpthread_cond_wait + 38 frame #3: 0x1cae037e libc++.1.dylib
std::1::condition_variable::wait(std::__1::unique_lock<std::1::mutex>&) + 118
frame #4: 0x21743728 JavaScriptCorevoid std::__1::condition_variable_any::wait<std::__1::unique_lock<bmalloc::Mutex> >(std::__1::unique_lock<bmalloc::Mutex>&) + 88 frame #5: 0x217436ac JavaScriptCore
bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::)()>::threadRunLoop() + 154
frame #6: 0x217435b4 JavaScriptCore`bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::)()>::threadEntryPoint(bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::)()>) + 10
thread #21, name = 'WebThread'
frame #0: 0x1d07b84c libsystem_kernel.dylibmach_msg_trap + 20 frame #1: 0x1d07b63e libsystem_kernel.dylib
mach_msg + 42
frame #2: 0x1d8a42f8 CoreFoundation__CFRunLoopServiceMachPort + 136 frame #3: 0x1d8a25f6 CoreFoundation
__CFRunLoopRun + 1014
frame #4: 0x1d7f1532 CoreFoundationCFRunLoopRunSpecific + 486 frame #5: 0x1d7f1340 CoreFoundation
CFRunLoopRunInMode + 104
frame #6: 0x219df8e2 WebCoreRunWebThread(void*) + 426 frame #7: 0x1d145a26 libsystem_pthread.dylib
_pthread_body + 216
frame #8: 0x1d14594c libsystem_pthread.dylib_pthread_start + 234 frame #9: 0x1d14349c libsystem_pthread.dylib
thread_start + 8
thread #22, name = 'JIT Worklist Worker Thread'
frame #0: 0x1d090810 libsystem_kernel.dylib__psynch_cvwait + 24 frame #1: 0x1d144d2e libsystem_pthread.dylib
_pthread_cond_wait + 542
frame #2: 0x1d1460be libsystem_pthread.dylibpthread_cond_wait + 38 frame #3: 0x1cae037e libc++.1.dylib
std::1::condition_variable::wait(std::__1::unique_lock<std::1::mutex>&) + 118
frame #4: 0x217314f4 JavaScriptCoreWTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1ll, 1000000000ll> > >) + 1812 frame #5: 0x215b9e60 JavaScriptCore
JSC::JITWorklist::runThread() + 192
frame #6: 0x215ba1ec JavaScriptCorestd::__1::__function::__func<JSC::JITWorklist::JITWorklist()::$_0, std::__1::allocator<JSC::JITWorklist::JITWorklist()::$_0>, void ()>::operator()() + 12 frame #7: 0x376a98a0 JavaScriptCore
vtable for std::1::function::__func<JSC::JITWorklist::JITWorklist()::$_0, std::__1::allocator<JSC::JITWorklist::JITWorklist()::$_0>, void ()> + 8
frame #8: 0x21283c7a JavaScriptCoreWTF::wtfThreadEntryPoint(void*) + 12 frame #9: 0x1d145a26 libsystem_pthread.dylib
_pthread_body + 216
frame #10: 0x1d14594c libsystem_pthread.dylib_pthread_start + 234 frame #11: 0x1d14349c libsystem_pthread.dylib
thread_start + 8
thread #23, name = 'WTF Parallel Helper Thread'
frame #0: 0x1d090810 libsystem_kernel.dylib__psynch_cvwait + 24 frame #1: 0x1d144d2e libsystem_pthread.dylib
_pthread_cond_wait + 542
frame #2: 0x1d1460be libsystem_pthread.dylibpthread_cond_wait + 38 frame #3: 0x1cae037e libc++.1.dylib
std::1::condition_variable::wait(std::__1::unique_lock<std::1::mutex>&) + 118
frame #4: 0x217314f4 JavaScriptCoreWTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1ll, 1000000000ll> > >) + 1812 frame #5: 0x21730c7a JavaScriptCore
WTF::ParallelHelperPool::waitForClientWithTask(WTF::LockerWTF::ParallelHelperPool::helperThreadBody() + 62 frame #7: 0x21283d1c JavaScriptCore
WTF::threadEntryPoint(void) + 146
frame #8: 0x21283c7a JavaScriptCore`WTF::wtfThreadEntryPoint(void) + 12
frame #9: 0x1d145a26 libsystem_pthread.dylib_pthread_body + 216 frame #10: 0x1d14594c libsystem_pthread.dylib
_pthread_start + 234
frame #11: 0x1d14349c libsystem_pthread.dylib`thread_start + 8
thread #24
frame #0: 0x1d091744 libsystem_kernel.dylib__workq_kernreturn + 8 frame #1: 0x1d1439a0 libsystem_pthread.dylib
_pthread_wqthread + 1274
frame #2: 0x1d143490 libsystem_pthread.dylib`start_wqthread + 8
thread #25
frame #0: 0x1d091744 libsystem_kernel.dylib__workq_kernreturn + 8 frame #1: 0x1d1437fc libsystem_pthread.dylib
_pthread_wqthread + 854
frame #2: 0x1d143490 libsystem_pthread.dylib`start_wqthread + 8
thread #26
frame #0: 0x1d091744 libsystem_kernel.dylib__workq_kernreturn + 8 frame #1: 0x1d1439a0 libsystem_pthread.dylib
_pthread_wqthread + 1274
frame #2: 0x1d143490 libsystem_pthread.dylib`start_wqthread + 8
Ah the crash is due to you passing a null string to GoogleAuthProvider::GetCredential();
You have... firebase::auth::GoogleAuthProvider::GetCredential(token.c_str(), nullptr);
You need to provide a valid access token. See https://firebase.google.com/docs/reference/cpp/class/firebase/auth/google-auth-provider
I'm not sure what you're trying to do but the code snippet you posted looks pretty incomplete for Google Sign-in.
I'm sure that I'm not passing an empty string. My test flow is next: sign in with google and save the token on the native side as an UserDefault value -> notify c++ side that sign in was successful and retrieve the token value -> call GetCredential() method passing it the token value saved before.
UPD. This is a dirty but clear example. It still crashes on the GetCredential() line
- (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
withError:(NSError *)error {
if (error == nil) {
GIDAuthentication *authentication = user.authentication;
std::string token = authentication.idToken.UTF8String;
if (token.empty())
return;
firebase::auth::Credential credential =
firebase::auth::GoogleAuthProvider::GetCredential(token.c_str(), nullptr);
}
}
The second argument to GetCredential is null, it shouldn't be.
`- (void)signIn:(GIDSignIn )signIn didSignInForUser:(GIDGoogleUser )user withError:(NSError )error { if (error == nil) { GIDAuthentication authentication = user.authentication;
std::string token = authentication.idToken.UTF8String;
if (token.empty())
return;
firebase::auth::Credential credential =
firebase::auth::GoogleAuthProvider::GetCredential(token.c_str(), **nullptr**);
}
}`
I was confused by the official tutorial (Authenticate with Firebase paragraph). Anyway I've should been checked the function signature. Thanks for your help
Well that tutorial looks a bit wrong :/ We'll get that fixed.
We took another look at this today and noticed that we should be handling null string arguments for the GoogleAuthCredential so it is definitely a bug in the SDK rather than the docs. We've fixed this internally and should have a release very soon.
Ok this is now fixed in version 4.0.0 https://firebase.google.com/support/release-notes/cpp-relnotes#4.0.0
Operating system: macos Operating system version: 10.12.3 CocoaPods version: 1.2.1 Firebase C++ SDK version: 3.1.2
Podfile contents:
platform :ios, '8.0'
target 'firebaseTest-mobile' do
use_frameworks!
pod 'Firebase/Core'
pod 'Firebase/AdMob'
pod 'Firebase/Auth'
pod 'GoogleSignIn'
pod 'Firebase/Database'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'
end
I'm trying to add Firebase C++ SDK to my cocos2d app. The app builds and runs successfully but when I add this piece of code:
std::string token = UserDefault::getInstance()->getStringForKey("GID"); firebase::auth::Credential credential = firebase::auth::GoogleAuthProvider::GetCredential(token.c_str(), nullptr);
a linker error appears:
Undefined symbols for architecture armv7: "_OBJC_CLASS_$_FIREmailPasswordAuthProvider", referenced from: objc-class-ref in firebase_auth(credential_ios_de0c3e1fa34e9a30835a63e195323a0f.o) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've added the
$(inherited)
flag to the Framework Search path, Other Linker Flags and Preprocessor Macros. The other suggestion from StackOverflow was to downgrade the pods version to 3.17.0. I tried it and this fixed the linker error but the app crashed in runtime on the same line of code and an exception was thrown'*** +[NSString stringWithUTF8String:]: NULL cString'
I also tried running the quickstart-cpp-master and the cocos2dx-cpp-sample but always got the same linker error.