I'd like to import runtime's header to use objc_msgSend but I'm getting:
error: NSObjCRuntime.h: No such file or directory
Should I add something to the header search path?
I'd like to import runtime's header to use objc_msgSend but I'm getting:
error: NSObjCRuntime.h: No such file or directory
Should I add something to the header search path?
You need to include <objc/message.h>
(you'll find the related headers in /usr/include/objc
) and link to the objc
(/usr/lib/libobjc.dylib
) library.
#import <Foundation/NSObjCRuntime.h>
does work
but you probably need
#import <objc/runtime.h>
upd: since iOS 7 #import <Foundation/NSObjCRuntime.h>
replaced to #import <objc/NSObjCRuntime.h>
but i recommend to use #import <objc/runtime.h>
anyway
objc_msgSend
is declared in <objc/message.h>
, not in <objc/runtime.h>
. So you will get a warning for implicitly declaring library function. –
Westfalen When using Xcode 6 and later, you will get an error after #include<objc/message.h>
. It can be resolved like this
#include <objc/message.h>
void foo(void *object) {
typedef void (*send_type)(id, SEL, int);
send_type func = (send_type)objc_msgSend;
func(object, sel_getUid("foo:"), 5);
}
http://devstreaming.apple.com/videos/wwdc/2014/417xx2zsyyp8zcs/417/417_whats_new_in_llvm.pdf
© 2022 - 2024 — McMap. All rights reserved.