Problem Description:

Recently, while accessing a company’s library that provides its own Git and uses Cocoapods to integrate their SDK, there was a problem: there was a private initialization method in the.m of a class:

- (instancetype)initWithJSONDictionary:(NSDictionary *)dictionary error:(NSError *__autoreleasing _Nullable *)error
Copy the code

However, an extension to this class is written by writing a header file, AylaSchedule+ internal. h:

@interface AylaSchedule (Internal)

- (instancetype)initWithJSONDictionary:(NSDictionary *)dictionary error:(NSError *__autoreleasing _Nullable *)error;

@end
Copy the code

Expose the method, but through the POD integrated library, import the Module with import, but the Module does not recognize the method in the class, and when it tries to call the method, it will be prompted that the method does not exist.

Solutions:

  1. New oc bridge joint (reference: www.jianshu.com/p/1f084b2f4.)
  2. Add the extension header import to the bridge:
#import "TestClass+Internal.h"
Copy the code
  1. New problems arise:



Xcode indicates that the header file cannot be found

Solution:

Header Search: Change User header search Paths to $(SRCROOT) and set it to recursive



Build again, you can call this method

To understand:

After adding the Settings, it will recursively search the header file under the project, and you can find the header file of the third party library introduced in the bridge file, but because of the recursive search, the subsequent compilation speed will be slower, especially the larger the project is, the more obvious the speed