문제

I'm building a static library to distribute to other folks to use in iOS apps, wherein I'd like to take advantage of of frameworks only if they have been included in the app by the users of my library. I've figured out how to compile the library so that it does not itself include any frameworks, but as soon as I try to use it in an app, it fails, because the library references frameworks that don't exist.

I'd rather not force my clients to load frameworks they don't need. Weak-linking frameworks is cool, but that just means that the framework doesn't have to be present on the system (e.g., for older versions of iOS); its support is still compiled into the binary. Better would be not to require the framework to be linked at all, and only use it if it is linked (optionally or not).

So, is there any way to detect that a framework is included in an iOS app at runtime, not just whether it's present on the system?

도움이 되었습니까?

해결책

you can use

if (NSClassFromString(@"FrameworkClass") == nil) {
   // the framework is not available
} else {
   // the framework is avaiable
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top