Search code examples
iphoneiosreachability

Reachability Runtime error - SCNetworkReachabilitySetDispatchQueue() failed: Permission denied


Here is my code:

Reachability *r = [Reachability reachabilityWithHostname:host];    
r.reachableBlock = ^(Reachability*reach)
{
    // Update the UI on the main thread

    });
};    
r.unreachableBlock = ^(Reachability*reach)
{
    // Update the UI on the main thread with error alert

    });
};    
[r startNotifier]; 

Upon running the last statement, I get following error logged, and it never executes any of the reachableBlock or unreachableBlock.

 SCNetworkReachabilitySetDispatchQueue() failed: Permission denied

For anyone wanting to know what I tried already, I also attempted this:

dispatch_async(dispatch_get_global_queue(0,0), ^{
    [r startNotifier];
});

But this yields same result. I logged an issue here.


Solution

  • This is no longer an issue.

    By some mysterious reasons, I cleaned up build folder, reset iOS simulator, relaunched it and recompiled - and the error is gone. I didn't succeed following these steps at first, but doing them just for the sake of trying, and it worked!