0

I'm working on an app that optionally requires Firebase to provide some additional functionality & thus, if it is linked to the project it should run some code.
This is what I've tried at the top of the ViewController:

#if defined(__has_include)
    #if __has_include(<FirebaseCore/FIROptions.h>) && __has_include(<FirebaseCore/FIRApp.h>)

        #include <FirebaseCore/FIROptions.h>
        #include <FirebaseCore/FIRApp.h>

        #ifndef FIREBASE_ENABLED
            #define FIREBASE_ENABLED
        #endif
    #endif
#endif

And then in the ViewControllers viewDidLoad()

#ifdef FIREBASE_ENABLED
    NSLog(@"*** FIREBASE ENABLED ***");
    FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:@"xxxx" bundleID:nil GCMSenderID:@"xxxx" APIKey:nil clientID:nil trackingID:nil androidClientID:nil databaseURL:@"https://xxxx.firebaseio.com" storageBucket:nil deepLinkURLScheme:nil];
    [FIRApp configureWithOptions:options];
#else
    NSLog(@"*** FIREBASE DISABLED ***");
#endif

Note that the code shows as highlighted in Xcode and clicking on any method takes to its header (even though the frameworks are unlinked): enter image description here I've added the frameworks to the project but I've unchecked the Target membership to test whether the code compiles properly should the required frameworks not be included. Below is a snapshot of the frameworks; required plus dependent as per Firebase's guidelines (all unlinked to the target):
enter image description here

However, when I build the project, I get build errors as follows: enter image description here

What am I doing wrong OR what is the right way to check for an external frameworks existence and conditionally run code based on it?

Appreciate any advice to resolve the issue.
Thanks in advance!

batman
  • 1,937
  • 2
  • 22
  • 41

0 Answers0