Xcode breakpoint not working inside dispatch_async block

Our team seriously needs help with the following problem that we are facing, as this prevents us from debugging part of the code inside the dispatch_async block.

I hope that I will receive help or suggestions on what to do next.

The problem we are facing is as follows:

We recently encountered some strange problem when in Xcode 6 we cannot break in the dispatch_async block.

- (void)viewDidLoad {

        dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);    

        dispatch_async(queue, ^{


        BOOL setRtn = TRUE;  //<- break point is set here but never break

        //call to function
        BOOL setFn = some_function();
        });

} 



- (BOOL) some_function()
{
     BOOL test = YES;   <- break point set here, breakpoint break!


     return test;
}

What happens when we set a breakpoint on any line in the dispatch_async block, the code never breaks and the breakpoint never works.

However, if we set a breakpoint in the function that is called by the dispatch_async block, the breakpoint works!

Does anyone else face the same problem?

Xcode 6.1 IOS8.1

, , , .

+5
4

, - New Relic. Relic, dispatch_async.

, , -, , .

, , , .

+10

, Grand Central Dispatch dispatch_async. GCD , prefix.pch :

#ifdef DEBUG
#undef dispatch_async 
#undef dispatch_sync 
#undef dispatch_after 
#undef dispatch_apply 
#undef _dispatch_once 
#endif
+11

, ( , ).

-O0 .

+1

, , " " Swift 4.2, DispatchQueue.main.async ; , .

I am using Xcode 10.1 and my optimization level build settings were already missing -O0, as suggested in other answers here.

0
source

All Articles