美文网首页iOSPod 使用 开发
iOS控制是否引入某个module

iOS控制是否引入某个module

作者: nick5683 | 来源:发表于2021-04-22 14:28 被阅读0次

对您有用了点个赞,开发过程遇到的知识点,也是我继续分享的动力

#if canImport(SomeModule)

import SomeModule;

#endif

This is a little late as an answer, but i came across this issue while working on a similar case. I used the __has_include(<SomeModule/SomeModule.h>)

Importing your framework:

#if __has_include(<SomeModule/SomeModule.h>)

#import <SomeModule/SomeModule.h>

#define __HAS_SOME_MODULE_FRAMEWORK__

#endif

Later in your code :

Objective-C:

- (void)doSomething {

    #ifdef __HAS_SOME_MODULE_FRAMEWORK__

    // with  SomeModule framework

    #else

    // without  SomeModule framework

    #endif

}

Swift:

  #if canImport(SomeModule)       

    // with  SomeModule framework

        #else

    // without  SomeModule framework

#endif

相关文章

网友评论

    本文标题:iOS控制是否引入某个module

    本文链接:https://www.haomeiwen.com/subject/irzxrltx.html