I work in a large existing objective-c codebase, currently writing unit tests. The project makes extensive use of instance variables.
I wrote a small method to grab ivar for something. It worked in another unit test in the same project, but does not work in this case.
the code:
-(id)getObjectForIvarNamed:(NSString *)ivarNameString
{
const char *ivarName = [ivarNameString UTF8String];
Ivar ivarValue = class_getInstanceVariable([textFieldOverlay class], ivarName);
id objectAtIvar = object_getIvar(textFieldOverlay, ivarValue);
return objectAtIvar;
}
The compiler complains about a line starting Ivar ivarValuewith the following error:
"Declaration of 'Ivar' must be imported from module 'ObjectiveC.runtime' before it is required"
A web search for this error code has zero images. Not sure why it works in another file, all the headers look the same between the two classes XCUnitTest.
source
share