Objective-C category is not loaded. How to debug this

I have two projects that have RestKit framework .

One project works without problems, but another project crashes as soon as the RestKit environment is used.

I found out that the error code is as follows:

return [anNSString MD5]; 

The MD5 method is a category method and is imported as follows:

 #import "NSString+MD5.h" 

However, in one project, I keep getting the following error:

 -[__NSCFString MD5]: unrecognized selector sent to instance 0x88a3390 

I understand the basics of categories and that they can be loaded at runtime, but I donโ€™t understand why the category does not load in this case.

These are the files in github: NSString + MD5.m , NSString + MD5.h ,

+6
source share
2 answers

Make sure the -ObjC flag is on. Or it will not link categories in a static library.

Objective-C categories in a static library

+19
source

It is not enough just to include the header file. You also need to compile and link the .m file in your project.

+7
source

Source: https://habr.com/ru/post/904994/


All Articles