firebase / quickstart-cpp

Firebase Quickstart Samples for C++
https://firebase.google.com/games
Apache License 2.0
206 stars 122 forks source link

without cocoapods #3

Closed pbljung closed 6 years ago

pbljung commented 7 years ago

Hi - I'm trying to get a firebase CPP database example running without using cocoapods since I am using Qt CPP. I tried to manually specify the frameworks in the Qt .pro file as

ios {
    QMAKE_LFLAGS += F/Users/me/Documents/firebase_cpp_sdk/libs/frameworks/universal
    LIBS += -framework firebase
    LIBS += -framework firebase_auth
    LIBS += -framework firebase_database
    QMAKE_INFO_PLIST = ios/Project-Info.plist
    OTHER_FILES += $$QMAKE_INFO_PLIST
    OTHER_FILES += google-services.json
}

but get link errors

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_FIRApp", referenced from:
      objc-class-ref in firebase(app_ios_0d9822969971d805b6c1fe1da95ac6eb.o)
  "_OBJC_CLASS_$_FIRAuth", referenced from:
      objc-class-ref in firebase_auth(auth_ios_f2d260118c71437a29dfd0bb1f84c2b2.o)
  "_OBJC_CLASS_$_FIRDatabase", referenced from:
      objc-class-ref in firebase_database(database_ios_d4065f07727b6295b21f7f78e32ac829.o)
  "_OBJC_CLASS_$_FIRDatabaseReference", referenced from:
      objc-class-ref in firebase_database(database_reference_ios_01d57dacac0312e7ded1b059f0eb08d5.o)
  "_OBJC_CLASS_$_FIROptions", referenced from:
      objc-class-ref in firebase(app_ios_0d9822969971d805b6c1fe1da95ac6eb.o)
  "_OBJC_CLASS_$_FIRTransactionResult", referenced from:
      objc-class-ref in firebase_database(database_reference_ios_01d57dacac0312e7ded1b059f0eb08d5.o)
ld: symbol(s) not found for architecture x86_64

How do I successfully link? Many thanks

larpon commented 7 years ago

You can use Cocoapods with Qt on iOS - is there any particular reason you won't use pods?

pbljung commented 7 years ago

I haven't seen any working examples of using cocoapods with the Qt qmake system. If you have a sample I would appreciate seeing it. https://bugreports.qt.io/browse/QTBUG-52696

First I used Qt to build a xcodeproj, and then add the pods to this. However install pods reports the same error as https://github.com/CocoaPods/Xcodeproj/issues/347

Next I tried the workaround in http://stackoverflow.com/questions/29071277/integrate-fabric-crashlytics-via-cocoapods, by linking to quickstart-cpp-master/database/testapp/Pods

The Qt pro file now looks like

ios {
    QMAKE_LFLAGS += $(inherited) -ObjC -F/Users/me/Documents/firebase_cpp_sdk/frameworks/ios/universal

    LIBS += -framework firebase
    LIBS += -framework firebase_auth
    LIBS += -framework firebase_database

# cocoapods + QT workaround as per https://github.com/GMaxera/QtFabric/blob/master/README.md
# change Pods/*.m sources to QtPods/*.mm
FIREBASE = /Users/me/Documents/quickstart-cpp-master/database/testapp/QtPods

# add libicucore.dylib to xcode as per http://stackoverflow.com/questions/35370611/getting-utf8-nextcharsafebody-error
    LIBS += -L/usr/lib -licucore

# some firebase sources need ARC support
    QMAKE_CXXFLAGS += -fobjc-arc

# frameworks from cocoapods
    LIBS +=  -F$$FIREBASE/FirebaseAnalytics/Frameworks/frameworks -framework FirebaseAnalytics
    LIBS +=  -F$$FIREBASE/FirebaseAuth/Frameworks/frameworks -framework FirebaseAuth
    LIBS +=  -F$$FIREBASE/FirebaseCore/Frameworks/frameworks -framework FirebaseCore
    LIBS +=  -F$$FIREBASE/FirebaseDatabase/Frameworks -framework FirebaseDatabase
    LIBS +=  -F$$FIREBASE/FirebaseInstanceID/Frameworks/frameworks -framework FirebaseInstanceID
    LIBS +=  -F$$FIREBASE/GoogleInterchangeUtilities/Frameworks/frameworks -framework GoogleInterchangeUtilities
    LIBS +=  -F$$FIREBASE/GoogleSymbolUtilities/Frameworks/frameworks -framework GoogleSymbolUtilities
# sources from cocoapods
    HEADERS += $$FIREBASE/Firebase/Core/Sources/Firebase.h
    HEADERS += $$FIREBASE/FirebaseInstanceID/Sources/FIRInstanceID.h
    HEADERS += $$FIREBASE/GoogleToolboxForMac/GTMDefines.h
    HEADERS += $$FIREBASE/GoogleToolboxForMac/DebugUtils/GTMDebugSelectorValidation.h
    HEADERS += $$FIREBASE/GoogleToolboxForMac/DebugUtils/GTMDebugSelectorValidation.h
    HEADERS += $$FIREBASE/GoogleToolboxForMac/DebugUtils/GTMMethodCheck.h
    HEADERS += $$FIREBASE/GoogleToolboxForMac/Foundation/GTMNSData+zlib.h
    SOURCES += $$FIREBASE/GoogleToolboxForMac/Foundation/GTMNSData+zlib.mm
    HEADERS += $$FIREBASE/GoogleToolboxForMac/Foundation/GTMNSDictionary+URLArguments.h
    SOURCES += $$FIREBASE/GoogleToolboxForMac/Foundation/GTMNSDictionary+URLArguments.mm
    HEADERS += $$FIREBASE/GoogleToolboxForMac/Foundation/GTMNSString+URLArguments.h
    SOURCES += $$FIREBASE/GoogleToolboxForMac/Foundation/GTMNSString+URLArguments.mm
    HEADERS += $$FIREBASE/GTMSessionFetcher/Source/GTMSessionFetcher.h
    SOURCES += $$FIREBASE/GTMSessionFetcher/Source/GTMSessionFetcher.mm
    HEADERS += $$FIREBASE/GTMSessionFetcher/Source/GTMSessionFetcherLogging.h
    SOURCES += $$FIREBASE/GTMSessionFetcher/Source/GTMSessionFetcherLogging.mm
    HEADERS += $$FIREBASE/GTMSessionFetcher/Source/GTMSessionFetcherService.h
    SOURCES += $$FIREBASE/GTMSessionFetcher/Source/GTMSessionFetcherService.mm
    HEADERS += $$FIREBASE/GTMSessionFetcher/Source/GTMSessionUploadFetcher.h
    SOURCES += $$FIREBASE/GTMSessionFetcher/Source/GTMSessionUploadFetcher.mm

    QMAKE_INFO_PLIST = ios/Project-Info.plist
    OTHER_FILES += $$QMAKE_INFO_PLIST
   # OTHER_FILES += ios/GoogleService-Info.plist

ios_google_plist.files = $$PWD/ios/GoogleService-Info.plist
    QMAKE_BUNDLE_DATA += ios_google_plist
}

which compiles and begins to run

Initialize Firebase Auth and Firebase Database.
2016-12-28 13:54:59.030 firebase2[15243] <Debug> [Firebase/Core][I-COR000001] Configuring the default app.
2016-12-28 13:54:59.032 firebase2[15243:] <FIRAnalytics/INFO> Firebase Analytics2016-12-28 13:54:59.039: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
 v.3600000 started
2016-12-28 13:54:59.043 firebase2[15243:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/Y0Yjwu)
2016-12-28 13:54:59.043 firebase2[15243:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2016-12-28 13:54:59.044 firebase2[15243:] <FIRAnalytics/WARNING> The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://goo.gl/9vSsPb
Attempt to initialize Firebase Auth.
Attempt to initialize Firebase Database.
Successfully initialized Firebase Auth and Firebase Database.
Starting anonymous auth
2016-12-28 13:54:59.046 firebase2[15243:] <FIRAnalytics/INFO> Firebase Analytics enabled
2016-12-28 13:56:00.040 firebase2[15243:1349311] CFNetwork SSLHandshake failed (-9806)

The loop in WaitForCompletion(sign_in_future, "SignInAnonymously"); is spinning with sign_in_future.Status()==kFutureStatusPending. Same if I try auth with email/password.

I cut & pasted the cpp initialization and first tests from the quickstart testapp. I've tried on both ios simulator 9.3 and iphone 9.3.5 on my mac 10.11.6. Building and running quickstart-cpp-master/database/testapp on the same simulator and device has no issues. Any ideas?

larpon commented 7 years ago

Hi and a happy new year :)

I can't answer for what your specific problem with SSLHandshake is - unfortunately. It seems you're compiling and linking just fine - but you might be missing a framework or framework dependency (these can be a little tricky to find)

But I can show you a working example of a Qt project using CocoaPods. I hadn't seen (and didn't know) any working CocoaPods integration before until I got a hint from @kafeg's work linked from this issue.

The trick is that you run your pod install on an empty XCode project (so you won't have to deal with the auto generated QMake one which uses a few tricks and have some quirks) - and then include and link against those pods.

I'm using @kafeg's method in this project - more specifically, you run pod install here: https://github.com/Larpon/QtFirebase/tree/master/src/ios/CocoaPods You can see how the frameworks and headers are included in the .pro file.

QtFirebase aims to bring all the components from the Firebase C++ SDK to wrapped Qt / QML components.

It lacks documentation - and I guess the pod install process could easily be automated so the project could be more "plug'n'play" capable (need more time) :)

Hope it helps - and contributions are welcome of course (QtFirebase needs a cool Auth and Database wrap - hint hint) :)

pbljung commented 7 years ago

Hi Larpon

Great, I can use this to follow in your footsteps.

However I wasn't able to compile your project QtFirebase using Qt5.7.1 for ios since some files are missing e.g. $$PWD/src/call_once.h \

$$PWD/src/singleton.h \

I see a reference to src/ios/Cocoapods/Empty/Pods in qtfirebase_target.pri,

and include(qtfirebase_target.pri) in qtfirebase.pri,

but I don't see any include(qtfirebase.pri) or similar in qtfirebase.pro

How does qtfirebase.pri run?

I'm wondering if this is the most recent tarball?

/Per

@pbljung mobile 408-609-1146 skype per.ljung google voice 510-394-4321

On Wed, Jan 4, 2017 at 3:46 AM, Larpon notifications@github.com wrote:

Hi and a happy new year :)

I can't answer for what your specific problem with SSLHandshake is - unfortunately. It seems you're compiling and linking just fine - but you might be missing a framework or framework dependency (these can be a little tricky to find)

But I can show you a working example of a Qt project using CocoaPods. I hadn't seen (and didn't know) any working CocoaPods integration before until I got a hint from @kafeg https://github.com/kafeg's work linked from this issue https://github.com/kafeg/adctl/issues/14.

The trick is that you run your pod install on an empty XCode project (so you won't have to deal with the auto generated QMake one which uses a few tricks and have some quirks) - and then include and link against those pods.

I'm using @kafeg https://github.com/kafeg's method in this project https://github.com/Larpon/QtFirebase - more specifically, you run pod install here: https://github.com/Larpon/QtFirebase/tree/master/src/ios/CocoaPods You can see how the frameworks and headers are included in the .pro https://github.com/Larpon/QtFirebase/blob/master/qtfirebase_target.pri#L47 file.

QtFirebase aims to bring all the components from the Firebase C++ SDK to wrapped Qt / QML components.

It lacks documentation - and I guess the pod install process could easily be automated so the project could be more "plug'n'play" capable (need more time) :)

Hope it helps - and contributions are welcome of course (QtFirebase needs a cool Auth and Database wrap - hint hint) :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/firebase/quickstart-cpp/issues/3#issuecomment-270353523, or mute the thread https://github.com/notifications/unsubscribe-auth/AXog04agCIGEUOc-OxBV0uYyD7O3QmIaks5rO4aHgaJpZM4LV5DI .

larpon commented 7 years ago

@pbljung - I'll be happy to help - I removed those two files a while back. Are you running off the master branch? Do you mind opening an issue in the QtFirebase project? That way I can keep track - and we won't hi-jack this thread (as it's not a Firebase issue) :) EDIT I also forgot to tell you about an example project I've set up - you should be able to check it out with git. I'll add some instructions in the README now :)

larpon commented 7 years ago

@pbljung Did you ever get this to work?

stewartmiles commented 6 years ago

@pbljung @Larpon do we need to keep this issue open or was this resolved?

larpon commented 6 years ago

@stewartmiles @pbljung - We switched away from using CocoaPods in QtFirebase in the latest release and now use the Google supplied iOS frameworks as part of our setup for iOS - which has proven to be much easier an cleaner.

So yes I'd say this can be closed :+1: