Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6 strange (null) object display in debugger

I'm seeing a strange behavior with Xcode 6 debugger. I have created a singleton shared instance using the following code:

+ (instancetype)shared 
{
    static DataBaseManager *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    sharedInstance = [[DataBaseManager alloc] init];
    });

   return sharedInstance;
}

Right after the object is initialized by calling the method like this:

DataBaseManager *manager = [DataBaseManager shared];
NSLog(@"");

I have placed a breakpoint on the "NSLog", and i'm seeing the following debugger status:

Xcode 6 debugger screen capture

I have made sure I'm launching on debug mode, and that the build settings are fine, following the question here: Xcode debugger doesn't print objects and shows nil, when they aren't

Any ideas on why this is happening? This is the first time i have ever seen this kind of strange behavior. Any help would be much appreciated.

**UPDATE**

A bug was reported to apple bug report system.
The bug status is: Duplicate of 17164538 (Closed) 

so it is probably a known bug in Xcode.
like image 647
Raz Avatar asked Oct 29 '14 14:10

Raz


3 Answers

You shouldn't be in Release mode while you are debugging your code.

If you want to see variable values you have to be in Debug mode. The steps are

  1. Click on your project name on the top left corner near start/stop buttons
  2. Go in Edit scheme
  3. Go in Run settings
  4. Go in Info tab and then Build Configuration
  5. Set it to Debug

If it was on "Release" that's the matter you saw all nil. If still not working then try following in the project Build Settings

  1. Set Strip debug symbols during copy to NO
  2. Optimization Level to None -O0
like image 90
Ans Avatar answered Oct 22 '22 17:10

Ans


Try setting Deployment Postprocessing to NO inside your Build Settings and check.

like image 32
Hussain Shabbir Avatar answered Oct 22 '22 15:10

Hussain Shabbir


Make sure you have Link-Time Optimization set to No for debug mode in Build Settings.

like image 38
llama591 Avatar answered Oct 22 '22 16:10

llama591