Include non-ARC library in an ARC app?

2019-01-24 10:02发布

问题:

So, is it possible?

I get this error multiple times:

ARC forbids Objective-C objects in structs or unions

For example here:

typedef struct {
    BOOL _field1;
    union {
        struct {
            id _field1;
            id _field2;
        } _field1;
        GSEventRef _field2;
    } _field2;
} XXStruct_CKAdxD;

回答1:

You need to add -fno-objc-arc to the compiler options for each file that doesn't / can't use ARC. Within Xcode you do this from the 'Compile Sources' build phase of your target. Double click the file and add -fno-objc-arc to the box that pops up.