I have following build env:
and try to build my application from QtCreator for iOS with the firebase support, but it fails with following linking errors:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FIRMessaging", referenced from: objc-class-ref in firebase_messaging(messaging_231c52c311096cfce13e67fa91eb9ac5.o)
"_OBJC_CLASS_$_FIRApp", referenced from: objc-class-ref in firebase(app_ios_814e1620d4f88024cea4bade26623a67.o)
"_OBJC_CLASS_$_FIROptions", referenced from: objc-class-ref in firebase(app_ios_814e1620d4f88024cea4bade26623a67.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have simplified my project to following code:
== main.cpp ==
#include <QCoreApplication>
#include <firebase/app.h>
#include <firebase/messaging.h>
#include <firebase/util.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
::firebase::App *fapp = ::firebase::App::Create();
Q_UNUSED(fapp);
return a.exec();
}
and a project file is:
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
# Check for GOOGLE_FIREBASE_SDK environment variable.
ENV_GOOGLE_FIREBASE_SDK = $$(GOOGLE_FIREBASE_SDK)
# Or define GOOGLE_FIREBASE_SDK path here.
GOOGLE_FIREBASE_SDK =
isEmpty(ENV_GOOGLE_FIREBASE_SDK) {
isEmpty(GOOGLE_FIREBASE_SDK) {
message("GOOGLE_FIREBASE_SDK" environment variable not detected!)
}
}
INCLUDEPATH += $$(GOOGLE_FIREBASE_SDK)
INCLUDEPATH += $$(GOOGLE_FIREBASE_SDK)/include
SOURCES += \
main.cpp
FCM_LIBS_PATH = $$(GOOGLE_FIREBASE_SDK)/frameworks/ios/universal
message("FCM_LIBS_PATH = $$FCM_LIBS_PATH")
LIBS += -F$$FCM_LIBS_PATH \
-framework firebase_messaging \
-framework firebase \
-framework Foundation \
-framework UserNotifications \
-framework UIKit \
-framework CoreGraphics
The firebase SDK contains different frameworks directories for different architectures:
As I see that error related to 'arm64' architecture, so, I have changed the project file LIBS to use 'arm64' instead of 'universal', but this does not help.
Also I tried to build the project from the XCode, using qmake's generated xcode.project file, but there are same error.
I looked on stackoverflow a similar issues, but that workarounds does not help:
I looked a code from the following projects:
But I don't understand why this linker error happens.. Maybe is it a qmake bug?
The error means the project lacks Firebase pod.
firebase_cpp_sdk
alone is not enough, in addition, it requires Firebase Core library.
In order add Firebase lib, you should migrate to use cocoapods.
In the project's source root, run pod init
a new file Podfile
would be then generated.
Open the file, add the following line to the target pod 'Firebase/Analytics'
and save the file.
After running pod update
successfully, open the .xcworkspace
and build as usual.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.