larpon / QtFirebase

An effort to bring Google's Firebase C++ API to Qt + QML
MIT License
284 stars 83 forks source link

Can QtFirebase be built standalone? #76

Closed sdzurenko closed 4 years ago

sdzurenko commented 6 years ago

Hi. I managed to build QtFirebaseExample and run it on iOS Simulator and my iPhone (6S, iOS 11.2.6). I have banner ads and interstitials running. I'm very excited to get this far. Thank you for making this code available! My issue... I was only able to get the QtFirebase build to succeed when run as part of the QtFirebaseExample build. So far, I have not been able to build QtFirebase on its own as a library. Do you expect this to be possible? Thank you.

sdzurenko commented 6 years ago

Right now I'm dealing with FirebaseCore.h not being found. I've hacked the .pro file a bit while trying to debug this, so the compiler output below might differ a tad from what you expect. I can't seem to find the magical combination for the FirebaseCore framework to be found during the build.

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -fPIC -std=gnu++11 -arch arm64 -arch x86_64 -Xarch_arm64 -miphoneos-version-min=10.0 -Xarch_arm64 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk -Xarch_x86_64 -mios-simulator-version-min=10.0 -Xarch_x86_64 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk -fobjc-nonfragile-abi -fobjc-legacy-dispatch -fembed-bitcode-marker -Wall -W -fPIC -DQT_COMPILER_SUPPORTS_SSE2 -DQTFIREBASE_AUTO_REGISTER -DQTFIREBASE_BUILD_ANALYTICS -DQTFIREBASE_BUILD_MESSAGING -DQTFIREBASE_BUILD_ADMOB -DQTFIREBASE_BUILD_REMOTE_CONFIG -DQTFIREBASE_BUILD_AUTH -DQTFIREBASE_BUILD_DATABASE -DQT_STATICPLUGIN -DQT_PLUGIN -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_QML_DEBUG -I../QtFirebase -I. -I../../Qt/Qt5.10.1/5.10.1/ios/mkspecs/common/uikit -I../QtFirebase -I../../FirebaseSDK/firebase_cpp_sdk/include -I../QtFirebase/src/ios/Firebase/Analytics/FirebaseCore.framework/Headers -I../../FirebaseSDK/firebase_cpp_sdk/include -I../QtFirebase/src -I../QtFirebase/src/ios -I../../Qt/Qt5.10.1/5.10.1/ios/include -I../../Qt/Qt5.10.1/5.10.1/ios/include/QtQuick -I../../Qt/Qt5.10.1/5.10.1/ios/include/QtGui/5.10.1 -I../../Qt/Qt5.10.1/5.10.1/ios/include/QtGui/5.10.1/QtGui -I../../Qt/Qt5.10.1/5.10.1/ios/include/QtGui -I../../Qt/Qt5.10.1/5.10.1/ios/include/QtQml -I../../Qt/Qt5.10.1/5.10.1/ios/include/QtNetwork -I../../Qt/Qt5.10.1/5.10.1/ios/include/QtCore/5.10.1 -I../../Qt/Qt5.10.1/5.10.1/ios/include/QtCore/5.10.1/QtCore -I../../Qt/Qt5.10.1/5.10.1/ios/include/QtCore -I. -I../../Qt/Qt5.10.1/5.10.1/ios/mkspecs/macx-ios-clang -o AppDelegate.o ../QtFirebase/src/ios/AppDelegate.mm In file included from ../QtFirebase/src/ios/AppDelegate.mm:4: ../QtFirebase/src/ios/Firebase/Firebase.h:1:9: fatal error: 'FirebaseCore/FirebaseCore.h' file not found

import <FirebaseCore/FirebaseCore.h>

    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 error generated. make: *** [AppDelegate.o] Error 1 18:17:19: The process "/usr/bin/make" exited with code 2. Error while building/deploying project qtfirebase (kit: Qt 5.10.1 for iOS) When executing step "Make"

larpon commented 6 years ago

@sdzurenko - I'm glad you got the example working! By "build QtFirebase on its own as a library" I guess you mean how do I get QtFirebase included in my own project - right?

As opposed to: "how do I build it as a dynamic shared library *.so (plugin) to include with my project and load later on" <- this part is still unexplored territory.

I can see you're using Qt 5.10.1 - but what versions of the Firebase (C++ / iOS) SDKs are you using? (TIP look in the readme's) :)

For a start it looks like the iOS SDK isn't included in the search path or something has changed in the SDK. Frameworks and libraries for iOS are included here: https://github.com/Larpon/QtFirebase/blob/master/qtfirebase_target.pri#L65-L112

Hmm - FirebaseCore is included here (from your output): -I../QtFirebase/src/ios/Firebase/Analytics/FirebaseCore.framework/Headers

sdzurenko commented 6 years ago

Yes, I am trying to include QtFirebase in my own project. But I am trying to build it on its own first and then just link to the pre-built library from my own project. I am not trying to build it as a dynamic shared library. In fact, I added CONFIG += static to the qtfirebase.pro file.

I just started this effort yesterday and downloaded all the necessary source code then, so I assume I'm using current versions. The Firebase C++ SDK, according to the Release Notes in readme.md, is version 4.5.1. The Firebase iOS SDK is version 5.0.1.

Yes, it is a bit confusing that some of the configuration set in qtfirebase_target.pri#L65-112 does not appear in the compile output. However, the build is getting inside that ios block. When building, I do see the output message "QtFirebase iOS base." I even added additional message("") calls to verify that L65-112 is being executed. See output below.

The path ../QtFirebase/src/ios/Firebase/Analytics/FirebaseCore.framework/Headers is included only because I explicitly added it to qtfirebase_target.pri while trying various things to make this work. However, I don't think this is the proper way to include framework headers. Since the library is imported as FirebaseCore/FirebaseCore.h, I wouldn't expect it to be found since there is no FirebaseCore directory under FirebaseCore.framework/Headers.

If I change the import line in Firebase.h from:

import <FirebaseCore/FirebaseCore.h>

to:

import

then the build succeeds. But I assume that hacking header file paths in the source code is not the proper solution here. Plus, there's also the fact that this problem does not occur when QtFirebase is built from the QtFirebaseExample build. So there's something that is being set by the QtFirebaseExample build that is not getting set properly in the QtFirebase build.

Project MESSAGE: STEVE: Include qtfirebase.pri Project MESSAGE: STEVE: Include qtfirebase_target.pri Project MESSAGE: QtFirebase: configuring build for supported Firebase target platform... Project MESSAGE: Using QTFIREBASE_SDK_PATH (/Users/steve/repositories/QtFirebase/../../FirebaseSDK/firebase_cpp_sdk) Project MESSAGE: QtFirebase iOS base Project MESSAGE: STEVE: LIBS is -framework FirebaseCore -F/Users/steve/repositories/QtFirebase/src/ios/Firebase//Analytics/ -ObjC -lsqlite3 -lz -L/Users/steve/repositories/QtFirebase/../../FirebaseSDK/firebase_cpp_sdk/libs/ios/universal/ -framework MediaPlayer -framework CoreMotion -framework CoreTelephony -framework MessageUI -framework GLKit -framework AddressBook -framework UIKit -framework SystemConfiguration -framework FirebaseCore Project MESSAGE: QtFirebase including AdMob Project MESSAGE: QtFirebase including RemoteConfig Project MESSAGE: QtFirebase including Messaging Project MESSAGE: QtFirebase Messaging requires iOS v10.x to build. Setting QMAKE_IOS_DEPLOYMENT_TARGET = 10.0 Project MESSAGE: QtFirebase including Analytics Project MESSAGE: QtFirebase including Auth Project MESSAGE: QtFirebase including Database Project MESSAGE: This project is using private headers and will therefore be tied to this specific Qt module build version. Project MESSAGE: Running this project against other versions of the Qt modules may crash at any arbitrary point. Project MESSAGE: This is not a bug, but a result of using Qt internals. You have been warned!

larpon commented 6 years ago

Hmm... Have you tried if #import <FirebaseCore.h> works with QtFirebaseExample? If #import <FirebaseCore.h> works in both cases (and fixes your problem) - I'll be happy to pull the change in.

Like you - I can't see what QtFirebaseExample should be doing differently

edit It could be some breaking change in the iOS SDK - AFAIK the major version I've tested was 4.x - so it could be that something moved around in 5.x

sdzurenko commented 6 years ago

Just tried and it does not work. If I change the import to

import

then the QtFirebaseExample build fails and complains that FirebaseCore.h cannot be found.

larpon commented 6 years ago

... weird. Maybe it's some Objective-C quirk or side effect? I'm running out of ideas

larpon commented 6 years ago

Would changing it to #import "FirebaseCore.h" or #import "FirebaseCore/FirebaseCore.h" make a difference?

sdzurenko commented 6 years ago

Are you able to build QtFirebase from qtfirebase.pro?

sdzurenko commented 6 years ago

No, changing to from < > to " " did not make a difference.

larpon commented 6 years ago

Are you able to build QtFirebase from qtfirebase.pro?

Yes - but I must admit it's been awhile since I tested that part on iOS (might even be before we added the AppDelegate.* files)

No, changing to from < > to " " did not make a difference.

Ok - just wanted to be sure - as we've had an issue with that elsewhere lately

larpon commented 6 years ago

Well - maybe it's the solution for now - that if static is defined it should use a different path for the include? :/ - I mean - if everything else works. I'd still like to know why though :-)

kshahim commented 5 years ago

I downloaded the latest qtfirebase and firebase ios frameworks and c++ sdks. in order to compile the qtfirebase standalone lib, i needed the following modifications:

1 ) #import <FirebaseCore/FirebaseCore.h> ——> #import

2 ) and add $$QTFIREBASE_FRAMEWORKS_ROOT/Analytics/FirebaseCore.framework/HEADERS in the following section for qtfirebase_target.pri

INCLUDEPATH += \
    $$QTFIREBASE_SDK_PATH/include \
    $$PWD/src \
    $$PWD/src/ios \
    $$QTFIREBASE_FRAMEWORKS_ROOT/Analytics/FirebaseCore.framework/HEADERS \
    \

The project compiles without error and i have the static lib as output -—> libqtfirebase.a (can we make this library separate for example for auth, analytics, and so on ?)

However I receive this warning:

...QtFirebase/src/ios/Firebase/Firebase.h:11: warning: "FirebaseAnalytics.framework is not included in your target. Please add Firebase/Core to your Podfile or add FirebaseAnalytics.framework to your project to ensure Firebase services work as intended." [-W#warnings]

On 18 May 2018, at 10:19, Larpon notifications@github.com wrote:

Would changing it to #import "FirebaseCore.h" or #import "FirebaseCore/FirebaseCore.h" make a difference?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Larpon/QtFirebase/issues/76#issuecomment-390132615, or mute the thread https://github.com/notifications/unsubscribe-auth/AYKMohHKgLDTH8ELdApCr2J2IURs2S-5ks5tzoQkgaJpZM4UCJ1D.

larpon commented 4 years ago

Closing due to inactivity