Cocoa Warning: Implicitly declaring C library function ‘objc_getClass’
In Slider 2, I needed to check for the presence for Sparkle, and only load Slider 2′s included version when Sparkle isn’t found.
The code I used to do this is included below, but the point of this article is really to provide a solution to the following warning I encountered:
warning: Semantic Issue: Implicitly declaring C library function 'objc_getClass' with type 'id (const char *)' |
One will get this warning if using code when checking for the existence of a class like:
if (!objc_getClass("SUUpdater")) { ... } |
The solution is to use NSClassFromString instead:
if (!NSClassFromString(@"SUUpdater")) { ... } |
For an in-depth tutorial on how to check for the presence of a framework within a Cocoa bundle, see Detecting Presence of a Framework Within an NSBundle (Plugin).


I wouldn’t call it a solution, but rather an alternative.
The solution to the error is: #import .
Thanks for commenting Edoardo, could you tell me what one would need to #import to allow use of objc_getClass without this error?
You need to include the Objective-C runtime (“#import “).
Gah my less than and greater than signs were stripped. Use “#import <objc/runtime>:”.