How to use Objective-C code with #define macros in Swift

后端 未结 3 1224
后悔当初
后悔当初 2020-12-03 10:00

I\'m trying to use a third-party Objective-C library in a Swift project of mine. I have the library successfully imported into Xcode, and I\'ve made a -

3条回答
  •  孤街浪徒
    2020-12-03 10:49

    I resolved this by replacing

    #define AD_SIZE CGSizeMake(320, 50)

    in the library's Constants.h with

    extern CGSize const AD_SIZE;

    and adding

    CGSize const AD_SIZE = { .width = 320.0f, .height = 50.0f };

    in the library's Constants.m file.

提交回复
热议问题