iOS:CocoaLumberjack:函数的隐式声明在c99中无效

问题描述:

我试图在我的应用程序框架中实现CocoaLumberjack,但我遇到了一些问题。这是我在我的AppDelegate.h实现:iOS:CocoaLumberjack:函数的隐式声明在c99中无效

#import "AppDelegate.h" 
#import <CocoaLumberjack/CocoaLumberjack.h> 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    [DDLog addLogger:[DDASLLogger sharedInstance]]; 
    [DDLog addLogger:[DDTTYLogger sharedInstance]]; 
    DDFileLogger *fileLogger = [[DDFileLogger alloc] init]; 
    fileLogger.maximumFileSize = 1024 * 1024; 
    fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling 
    fileLogger.logFileManager.maximumNumberOfLogFiles = 7; 
    [DDLog addLogger:fileLogger]; 
    DDLogWarn(@"blablabla"); 
    DDLogError(@"Broken sprocket detected!"); 
    DDLogVerbose(@"User selected file:%@ withSize:%u", @"temp/test/log.txt", 100000); 
    return YES; 
} 

在应用程序委托没有问题。但在我的ViewController:

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    DDLogError(@"something when wrong!!!"); // <-- implicit declaration of function is invalid in c99 
} 

implicit declaration of function is invalid in c99 任何的你知道什么是错的或解决此错误的任何工作?

我真的很感谢你的帮助。

+0

这意味着编译无法找到DDLogError的定义。你在viewcontroller.m文件中加入了可可伐木工头吗? – Byron

+0

@Byron,我将这添加到viewController #import ,它解决了C99错误,但现在我得到这个错误:“使用未声明的标识符ddloglevel” – user2924482

添加以下行:

#define LOG_LEVEL_DEF ddLogLevel 
#import <CocoaLumberjack/CocoaLumberjack.h> 

访问和配置Getting Started文件的框架部分。

+0

由于某些原因,它不起作用为了我。我修正了添加这个:#import #if DEBUG static const DDLogLevel ddLogLevel = DDLogLevelVerbose; #else static const DDLogLevel ddLogLevel = DDLogLevelWarning; #endif – user2924482