How to set up QtFirebase for inclusion and to utilize Firebase modules in your project.
For a working and up-to-date example that can be compiled in Qt Creator please follow the Quick start section found in the QtFirebaseExample README. (The example app links back here in some places - but not all). It's strongly adviced to see how the example app is setup in-order to avoid any missing entries.
QtFirebase rely on a relativly large software stack. Many common errors people encounter with QtFirebase is due to little or no knownledge of the complete stack of technology used. It's therefore stongly adviced that developers, as a minimum, know or familiarize themselves with the following software in general before diving into the project.
In general Firebase, Firebase C++ SDK, Qt, QML, QMake
Android specific Gradle, Android SDK, Android NDK, Java
iOS specific XCode, Firebase iOS SDK
Clone the QtFirebase project
Clone into the "extensions" or "vendor" folder or into another folder of your choice. Here we use the QtFirebaseExample structure.
cd /path/to/projects/QtFirebaseExample/extensions
git clone git@github.com:Larpon/QtFirebase.git
Download and extract the latest version of Google's Firebase C++ SDK.
cd /path/to/download
curl --location https://firebase.google.com/download/cpp --output "firebase_cpp_sdk.zip"
unzip firebase_cpp_sdk.zip -d /path/to/sdk
rm firebase_cpp_sdk.zip
If you have multiple projects using QtFirebase it's a space-saver to have the Firebase C++ SDK (~832 MB) in one place.
You can either symlink the Firebase C++ SDK to the default search path OR set the QTFIREBASE_SDK_PATH
variable to the absolute path of the SDK in your project's .pro
file for the app build.
ln -s /path/to/sdk/firebase_cpp_sdk /path/to/projects/QtFirebase/firebase_cpp_sdk
Open your project with Qt Creator.
Navigate to the .pro
(sub)project file in the Project pane.
QtFirebaseExample
|_...
|_App
|_App.pro
Locate the lines:
# NOTE QTFIREBASE_SDK_PATH can be symlinked to match $$PWD/firebase_cpp_sdk
...
Change it to match your path(s) - or leave it to use default $$PWD/firebase_cpp_sdk
QTFIREBASE_SDK_PATH = /path/to/sdk/firebase_cpp_sdk
(Example)
In your project's .pro
(sub)project file (before including qtfirebase.pri
) - choose the modules to include:
QTFIREBASE_CONFIG += analytics messaging admob remote_config
(Example)
Finally include qtfirebase.pri
in your project's .pro
file.
include(/path/to/QtFirebase/qtfirebase.pri)
(Example)
If you're planing on compiling QtFirebase as part of a library in your project, please be aware that QtFirebase in this case will omit registering of it's QML types. This is due to how Q_COREAPP_STARTUP_FUNCTION works. So for auto registering of QML to work - QtFirebase need to be built as an app. Otherwise you must register the types manually.
Currently we haven't tested the parts of Firebase C++ SDK that have desktop support.
QtFirebase provides stub implementations ("empty shells" or "placeholders") for desktop builds and no firebase libraries are linked to the application - this may change depending on what parts of the SDK Google make available for desktop builds in the future.
When building QtFirebase for Android targets a few extra steps is needed. Please see SETUP_ANDROID.
When building QtFirebase for iOS targets a few extra steps is needed. Please see SETUP_IOS.
Congratiolations! You fought through the setup - pad yourself on the back!
This is kind of where we leave you off as a developer. Why? Because your entering Google's domain - and your project's specific setup. Firebase and AdMob are (mostly) closed platforms. Any problems with Ad fill-rates and backend messaging are out of scope for this project. The QtFirebase project only provide Qt wrapper classes - that's it.
If you want to know more about how things really work please refer to the official documentation of the respective projects:
Documentation:
Troubleshooting
Community