tags:

views:

138

answers:

1

Is there any way to determine whether the Accelerate.framework is available at runtime from straight C or C++ files?

The examples I've found for conditional coding all seem to require Objective-C introspection (e.g., respondsToSelector) and/or Objective-C apis (e.g., UIDevice's systemVersion member)

+2  A: 

The usual trick for this is that you weak link against the framework and then check a function pointer exported by that framework for the actual availability. If the framework failed to link because it is not available then the function will be NULL.

So for Accelerate.framework you would do something like this:

#include <Accelerate/Accelerate.h>

if (cblas_sdsdot) {
    NSLog(@"Yay we got Accelerate.framework");
} else {
    NSLog(@"Oh no, no Accelerate.framework");
}

This is described in TN2064 - Ensuring Binary Backwards Compatibility

St3fan
Ah, and the availability macros automatically handle the weak-linking. So simple! Thanks!
Art Gillespie
tc.