Strange compiler error during ShareKit integration

2019-07-16 12:11发布

I tried integrate ShareKit in my project and I face a problem.

By the time I include the ShareKit classes in my classes project folder the compiler gets errors like

"Parse Issue. Unknown type name 'NSUInteger'" or "Parse Issue. Unknown type name 'NSString'"

in the MyProject_Prefix.pch file.

The variables I defined in the prefix file are globally used by my application. I have never got this kind of error before untill I included the ShareKit classes in my project.

Thanks in advance.

1条回答
干净又极端
2楼-- · 2019-07-16 12:39

I managed to solve this issue by moving all #import declarations and any other Objective-c code inside the #ifdef __OBJC__ section.

So for example, if your pch file looks like this, it will cause compilation errors:

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif
#import <CoreData/CoreData.h>
typedef void (^BasicBlock)();

It must look like this, and those errors should go away:

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import <CoreData/CoreData.h>
    typedef void (^BasicBlock)();
#endif
查看更多
登录 后发表回答