检查框架

时间:2016-10-27 05:40:53

标签: ios objective-c xcode firebase

我正在开发一款可选择要求Firebase提供额外功能的应用。因此,如果它与项目相关联,它应该运行一些代码 这就是我在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

然后在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

请注意,代码在Xcode中突出显示,并且单击任何方法都会显示在其标题中(即使框架已取消链接): enter image description here 我已经将框架添加到项目中,但是我已经取消选中Target成员资格来测试代码是否在未包含所需框架的情况下正确编译。下面是框架的快照;根据Firebase的指南要求加上依赖性(所有指标都与目标无关):
enter image description here

但是,当我构建项目时,我得到如下构建错误: enter image description here

我做错了什么或检查外部框架存在的正确方法是什么,并基于它来有条件地运行代码?

感谢任何解决问题的建议 提前谢谢!

0 个答案:

没有答案
相关问题