Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt && firebase C++ SDK linking issues on iOS

I have following build env:

  • host: OSX 10.12 Sierra
  • XCode 9.2
  • Qt 5.10.1 for iOS
  • QtCreator 4.7.0
  • firebase 5.2

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 :

  • ~/firebase_cpp_sdk/frameworks/ios/universal
  • ~/firebase_cpp_sdk/frameworks/ios/amd64
  • ~/firebase_cpp_sdk/frameworks/ios/i386
  • ~/firebase_cpp_sdk/frameworks/ios/x86_64
  • ~/firebase_cpp_sdk/frameworks/ios/armv7

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 tried to remove the /Users/admin/Library/Developer/Xcode/DerivedData directory.
  • I tried to play with the XCode options "Build Settings -> Build Active Architecture Only -> yes|no"

I looked a code from the following projects:

  • qtcloudmessaging: https://github.com/qt/qtcloudmessaging
  • QtFirebase: https://github.com/Larpon/QtFirebase

But I don't understand why this linker error happens.. Maybe is it a qmake bug?

like image 868
Denis Shienkov Avatar asked Dec 13 '25 17:12

Denis Shienkov


1 Answers

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.

like image 61
zero-point Avatar answered Dec 15 '25 08:12

zero-point



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!