28

I am currently using blocks in my UIButton category. However I have come across this error which I cannot solve:

error: /usr/include/objc/objc-class.h: No such file or directory

This is the line of code that uses blocks:

FTButtonBlock block = objc_getAssociatedObject(self, "buttonBlock");
TheLearner
  • 19,387
  • 35
  • 95
  • 163

3 Answers3

66

Change

#import <objc/objc-class.h>

to

#import <objc/runtime.h>

From the blog entry: error: objc/objc-class.h: No such file or directory

Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76
3

Replace current line with following line:

#import <objc/runtime.h>

Thanks.

Hemang
  • 1,224
  • 9
  • 15
0

After xcode 4.6 this breaks again. I just fixed this like this :

cd /usr/include/
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/objc .

Now it works like a charm

Trausti Thor
  • 3,722
  • 31
  • 41