Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

XcodeColors doesn't work #50

Closed
lanvige opened this Issue Aug 3, 2012 · 30 comments

Comments

Projects
None yet

lanvige commented Aug 3, 2012

I follow the step to configured the xcode but the content in output did't render with color but with messy code.

    //Adds the logger to the console (similar to nslog)
    [DDLog addLogger:[DDTTYLogger sharedInstance]];
    // And we also enable colors
    [[DDTTYLogger sharedInstance] setColorsEnabled:YES];

    DDLogWarn(@"waring");
    DDLogError(@"error");
[38;5;130m2012-08-03 22:22:50:735[10875:c07] waring
�[0m�[38;5;124m2012-08-03 22:22:50:735[10875:c07] error
�[0m

[38;5;130m and �[0m�[38;5;124m are the messy code.

I also test with xcodecolor test project and it works fine.

Thanks.

having exactly the same problem!

neoneye commented Mar 18, 2013

You need to go to "Edit Scheme..."
Select the "Run" -> "Arguments"
Under "Environment Variables"
Click the "+" button.
In the "Name" column enter: "XcodeColors"
In the "Value" column enter: "YES"

neoneye commented Mar 18, 2013

Or do like this

#if TARGET_IPHONE_SIMULATOR
    // Sends log statements to Xcode console - if available
    setenv("XcodeColors", "YES", 1);
    [DDLog addLogger:[DDTTYLogger sharedInstance]];
    [[DDTTYLogger sharedInstance] setColorsEnabled:YES];
#endif

@neoneye already tried to set XcodeColors var :(
The problem seems to happen only on ios projects

Contributor

robbiehanson commented Apr 2, 2013

Have you properly installed the XcodeColors plugin?

https://github.com/robbiehanson/XcodeColors

@robbiehanson yes, i setup an osx project and worked fine! The problem seems to be in ios projects only

I seem to be having the same problem...
XCodeColors is installed and the test project works.
I have the environment variable set.

If I setColorsEnabled:YES then I get junk in the console. NO removes the junk. No colors in either case.

iOS 6.1 in the iPad Simulator.

Same problem. Demo Project works fine, but No colours in iOS project.

It's ok for me now :
I used the following path
~/Library/Developer/Shared/Xcode/Plug-ins/XcodeColors.xcplugin
instead of that one
~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XcodeColors.xcplugin

Stupid me

I had the same problem and to fix it you need some defines:

#define XCODE_COLORS_ESCAPE_MAC @"\033["
#define XCODE_COLORS_ESCAPE_IOS @"\xC2\xA0["

#if TARGET_OS_IPHONE
#define XCODE_COLORS_ESCAPE  XCODE_COLORS_ESCAPE_IOS
#else
#define XCODE_COLORS_ESCAPE  XCODE_COLORS_ESCAPE_MAC
#endif

Or you can just use:

#define XCODE_COLORS_ESCAPE  @"\xC2\xA0["

Enjoy!

Member

bpoplauschi commented Nov 1, 2013

XcodeColors was recently updated and works fine, even on Xcode5.

@bpoplauschi bpoplauschi closed this Nov 1, 2013

Narayane commented Feb 5, 2014

Hi,
I still have this problem in Xcode 5.0.2 with last master version of XcodeColors and CocoaLumberjack 1.8.0.
XcodeColors plugin is in the right place ("~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XcodeColors.xcplugin"), I have also defined XcodeColors env variable in debug scheme of my simulator but I have this result in my console with TestXcodeColors target:

xcodecolors

Any advise would be appreciated.
Regards.

drspin commented Feb 5, 2014

Same thing here... tried all of the above but no dice. xcodecolors test and nslog defined with colors work but not cocoalumberjack ddlog.

Contributor

robbiehanson commented Feb 5, 2014

The XcodeColors project has been updated to support Xcode 5.1 Beta 5.

In addition, I added a new wiki article that details how to fix XcodeColors when new versions of Xcode "break" it:

https://github.com/robbiehanson/XcodeColors/wiki/XcodeUpdates

Member

rivera-ernesto commented Feb 6, 2014

It works for me. What is weird is that in some projects I need to add the XcodeColors environment variable and in some others it's not necessary.

2014-02-06 11 34 53

Narayane commented Feb 6, 2014

Hi,
@robbiehanson: your code last update on master branch solves my problem. I have colors in my xcode console now. I need no more XcodeColors env variable in my debug scheme.
Thanks a lot.

Contributor

robbiehanson commented Feb 6, 2014

@rivera-ernesto This should probably be documented better. I just noticed I only ever mention it here:

https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/XcodeColors#xcodecolors-and-ios

"The XcodeColors plugin is automatically loaded by Xcode when Xcode launches. When XcodeColors runs, it sets the environment variable "XcodeColors" to "YES". Thus the Xcode application itself has this environment variable set.

It is this environment variable that Lumberjack uses to detect whether XcodeColors is installed or not. Because if Lumberjack injects color information when XcodeColors isn't installed, then your log statements have a bunch of garbage characters in them.

Now any application that Xcode launches inherits the environment variables from Xcode. So if you hit build-and-go, and Xcode launches the simulator for you automatically, then the colors will work. But if you manually launch the simulator, then it doesn't inherit environment variables from Xcode (because Xcode isn't the process' parent in this case). It's a similar problem when debugging on the actual device."

drspin commented Feb 6, 2014

Thank you very much @robbiehanson -- it works now.

I am not able to run XcodeColors. I have followed all the instructions. I have verified that the plugin has been copied to the right place, where all other plugins reside. But after compiling and restarting the xcode , when I try to run the XcodeColors project, it just builds and never runs. cmd+R is not working and Run option is coming disabled in Product menu. I think I am doing some stupid mistake.

Hi,
@robbiehanson I downloaded latest zip and tried to build Plugin, I verified, that Xcode UDID is included to the plist of new project, but after i build it and reopen - my Xcode breaks and never open again. If I remove plugin from Library/ApplicationSupport/Developer/Xcode/... then it works again. It's strange. By the way, when I open project, I get message that "Garbage collectors are not supported" and you need to upgrade your project. Upgrading didn't fix the problem. Look forward to some tips and help. Thx!

If you're stuck with CocoaLumberjack 1.6 because of some CocoaPods dependencies (XMPPFramework) and still can't figure out how to make XcodeColors work with the iPhone Simulator in spite of all that is said in this page, I've found a trick that can help.

Call:

unsetenv("TERM");

in your application:didFinishLaunchingWithOptions: before you initialize CocoaLumberjack and you should be OK.

ps : in my case, TERM was set to "xterm-256color" which caused a if statement in DDTTYLogger to not consider colors. It seems fixed in today's master version so I'll try to update the pod spec of my dependency to version 1.8 soon and see if i can remove unsetenv but it does the trick so far.

@dirtyhenry dirtyhenry referenced this issue in robbiehanson/XMPPFramework May 22, 2014

Merged

Upgraded CocoaLumberjack to version 1.8.1 #377

Member

rivera-ernesto commented May 23, 2014

By the way:

If you're stuck with CocoaLumberjack 1.6 because of some CocoaPods dependencies (XMPPFramework)

I think updating most libraries to the current CocoaLumberjack would require a simple version change in the podspecs.

nateuni commented May 15, 2015

I am having the same issue in CocoaLumberjack (installed from cocoapods) with Swift.

Though even when I build XcodeColors... close xcode and reopen I see nothing in the terminal.

  1. I can see the XcodeColors plug in "~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XcodeColors.xcplugin"
  2. In CocoaaLumberjack in my AppDelegate I have set:
        DDLog.addLogger(DDASLLogger.sharedInstance())
        DDLog.addLogger(DDTTYLogger.sharedInstance())
        DDTTYLogger.sharedInstance().colorsEnabled = true
  1. I have checked the plist file as stated here
  2. I went into the scheme editor and added XcodeColors as stated here.

XCode Version 6.3.2 (6D2102)

platform :ios, '8.3'
use_frameworks!

target 'myApp' do
 link_with ['myApp', 'myAppTests']
 pod 'CocoaLumberjack', :git => 'https://github.com/CocoaLumberjack/CocoaLumberjack.git', :branch => 'swift_support'
 pod 'FMDB', :git => 'https://github.com/robertmryan/fmdb.git'
 pod 'FBSDKCoreKit', :git => 'https://github.com/facebook/facebook-ios-sdk.git', :branch => 'dev'
 pod 'FBSDKLoginKit', :git => 'https://github.com/facebook/facebook-ios-sdk.git', :branch => 'dev'
end

Running out of options.. anyone got a fix for this?

Using Xcode 6.3.2 I had the same problem as @nateuni although I'm using Obj-C in combination with the Cocoapod. Once I added the env var using 'edit scheme' things started working for me. My test code that I use in application:didFinishLaunchingWithOptions: is:

#import <CocoaLumberjack/CocoaLumberjack.h>

@interface AppDelegate ()
@property (strong, nonatomic) DDFileLogger *fileLogger;
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ...
    [DDLog addLogger:[DDASLLogger sharedInstance]];
    [DDLog addLogger:[DDTTYLogger sharedInstance]];
    [[DDTTYLogger sharedInstance] setColorsEnabled:YES];

    DDFileLogger *fileLogger = [[DDFileLogger alloc] init];
    fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
    fileLogger.logFileManager.maximumNumberOfLogFiles = 7;

    [DDLog addLogger:fileLogger];
    self.fileLogger = fileLogger;

    // pinkify all the things
    UIColor *pink = [UIColor colorWithRed:(255/255.0) green:(58/255.0) blue:(159/255.0) alpha:1.0];
    [[DDTTYLogger sharedInstance] setForegroundColor:pink backgroundColor:nil forFlag:DDLogFlagInfo];
    [[DDTTYLogger sharedInstance] setForegroundColor:pink backgroundColor:nil forFlag:DDLogFlagWarning];
    [[DDTTYLogger sharedInstance] setForegroundColor:pink backgroundColor:nil forFlag:DDLogFlagDebug];

    DDLogInfo(@"Warming up printer (post-customization)"); // Pink

    DDLogDebug(@"%s", __PRETTY_FUNCTION__);
    ...
    return YES;
}

screen shot 2015-05-26 at 10 49 05

screen shot 2015-05-26 at 10 50 54

nateuni commented May 29, 2015

I have the env var set exactly the same, but still no colours. It is set for the main project, should it be set for something else?

Member

rivera-ernesto commented May 29, 2015

It is also case sensitive.

@bpoplauschi bpoplauschi added this to the Future milestone Oct 23, 2015

Member

bpoplauschi commented Oct 23, 2015

Any updates here? Does XcodeColors still fail to work?

Member

rivera-ernesto commented Oct 23, 2015

Closing this for now. Feel free to update/reopen.

@paradoxally paradoxally referenced this issue in robbiehanson/XcodeColors Dec 13, 2015

Open

Xcode 7.2 Issue #72

I have followed all steps but still failed to work

@MadBurea: if you're using Xcode 8+, XcodeColors is not supported any more: cf. https://github.com/robbiehanson/XcodeColors's README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment