简体   繁体   English

iOS - 确定Accelerate.framework是否在运行时可用

[英]iOS — Determining whether Accelerate.framework is available at runtime

Is there any way to determine whether the Accelerate.framework is available at runtime from straight C or C++ files? 有没有办法确定Accelerate.framework在运行时是否可以从直接的C或C ++文件中获得?

The examples I've found for conditional coding all seem to require Objective-C introspection (eg, respondsToSelector ) and/or Objective-C apis (eg, UIDevice's systemVersion member) 我发现条件编码的例子似乎都需要Objective-C内省(例如, respondsToSelector )和/或Objective-C apis(例如,UIDevice的systemVersion成员)

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 . 如果框架由于不可用而无法链接,则该函数将为NULL

So for Accelerate.framework you would do something like this: 所以对于Accelerate.framework你会做这样的事情:

#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 TN2064中描述了这一点- 确保二进制向后兼容性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM