-
Notifications
You must be signed in to change notification settings - Fork 122
Use in Debug environment
Typically, when you only want to use a library in a Debug environment
, you'll write a line in Podfile like this pod 'LLDebugTool':configurations => ['Debug']
.
When you integrate in this way, you will find that your code will have a lot of errors in the Release environment
, and you can solve most of the LLDebugTool
and LLConfig
errors in the following ways. You can ensure that this code is only compiled in a Debug environment
by wrapping the LLDebugTool
code in #ifdef DEBUG
and #endif
.
#ifdef DEBUG
#import "LLDebug.h"
#endif
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#ifdef DEBUG
[LLConfig sharedConfig].userIdentity = @"Your user Identity";
[[LLDebugTool sharedTool] startWorking];
#endif
}
If it's an LLog macro
or any other LLog macro
, it's especially silly to do this because you need to add a #ifdef DEBUG
and #endif
before and after every LLog macro
everywhere. To solve this problem, look at the LLDebugToolMacros.h
and copy the following code into your PCH file.
// Your PCH file.
#ifndef DEBUG
#define LLog(fmt, ...) NSLog(fmt)
#define LLog_Event(event , fmt , ...) NSLog(fmt)
#define LLog_Alert(fmt, ...) NSLog(fmt)
#define LLog_Alert_Event(event, fmt , ...) NSLog(fmt)
#define LLog_Warning(fmt, ...) NSLog(fmt)
#define LLog_Warning_Event(event, fmt , ...) NSLog(fmt)
#define LLog_Error(fmt, ...) NSLog(fmt)
#define LLog_Error_Event(event, fmt , ...) NSLog(fmt)
#endif
This solves all the reporting errors, and the LLog macro
calls the LLDebugTool
method when the DEBUG environment
is run, and NSLog
methods when the Release environment
is run.
Coming soon.