Want to complete a color log in Xcode, follow the steps in the GETTINGSTARTED.MD article to integrate Cocoalumberjack 2.x into my project, encountered some problems, of course, there are some pits, make a record.
Integration steps:
Drag into CocoaLumberjack/Framework/{Desktop/Mobile}/Lumberjack.xcodeproj your project
In your App target Build Settings
In your App target Build phases
Include the framework in your source files with
#import <CocoaLumberjack/CocoaLumberjack.h>
1. The first is to compile the hint use of undeclared identifier ' log_level_verbose ' problem
This is what I did. The following code is added to the PCH file according to document XCODETRICKS.MD:
#ifdef DEBUG static const int ddloglevel = log_level_verbose; #else static const int ddloglevel = Log_level_warn; #endif
Step on the Pit 1, the log_level_verbose and Log_level_warn replaced with Ddloglevelverbose and Ddloglevelerror just fine.
The modified code should be:
#ifdef debugstatic const int ddloglevel = ddloglevelverbose; #elsestatic const int ddloglevel = Ddloglevelerror; #endif
Then add the following code in method Application:didfinishlaunchingwithoptions: To set the color display:
[Ddlog Addlogger:[ddasllogger sharedinstance]; [Ddlog Addlogger:[ddttylogger sharedinstance]; [[Ddttylogger sharedinstance] setcolorsenabled:yes];
To test the color display code:
Ddlogerror (@ "Paper jam");DD Logwarn (@ "Toner is low");DD Loginfo (@ "Warming up Printer (pre-customization)");D Dlogverbose (@ "intializing protcol x26 (pre-customization)");
2, color log display needs plug-in Xcodecolors plug-in support, this plugin i download is https://github.com/rvi/XcodeColors inside, because it supports the Xcode6.3.
3, with Cocoalumberjack demo textxcodecolors Engineering test, pod install after open textxcodecolors.xcodeproj, compile prompt ld:library not found for -lpods-txc_ios-cocoalumberjack
Again a pit. In general, you should generate a Xcworkspace file after the pod install, but without generating the Textxcodecolors.xcworkspace file, I'm surprised. Later found that should be open demos.xcworkspace, and then choose Textxcodecolors This target, of course, the premise is to go into the Textxcodecolors folder to perform pod install. Use "Pod install--verbose--no-repo-update" as much as possible
4, the demo test log color is normal, in their own projects will not show the color
Pit 3. The secret is to make the following adjustments to project's scheme:
In Xcode bring up the scheme Editor (Product---Edit scheme ...)
Select "Run", and then the "Arguments" tab
ADD a new environment Variable named "Xcodecolors" with a value of "YES"
Reference:
iOS Open source project log Framework Cocoalumberjack
Use Cocoalumberjack to build your own Log system
Colorful XCode Console
Configure some problem records for Cocoalumberjack