iOSPod 使用 开发

iOS控制是否引入某个module

2021-04-22  本文已影响0人  nick5683

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

#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

上一篇下一篇

猜你喜欢

热点阅读