Undeclared identifier "UIColor" in my tweak in Objective C

junyi00 picture junyi00 · Feb 11, 2013 · Viewed 10.5k times · Source

I am trying to make a tweak in Xcode with IOSOpenDev, but i met an error which is Use of undeclared identifier "UIColor"!
I used the same code from my iPhone yet it works, why doesn't it work here? (I want to use IOSOpenDev since it looks much better then using theos)

This is the code

%hook SBScreenFlash

-(void)flashColor:(id)color {

NSDictionary *prefs=[[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.junyi00.screenshotcolor.plist"];

if ([[prefs objectForKey:@"enable"] boolValue]){
    color = [UIColor blueColor];
    %orig(color); }
else {
    %orig; }
}

%end

Please help me here

Answer

s6luwJ0A3I picture s6luwJ0A3I · Feb 16, 2013

You should check if you have

PROJECTNAME_FRAMEWORKS = UIKit Foundation

Also

#import <UIKit/UIKit.h>

In your tweak.xm (On the top) like this

#import <UIKit/UIKit.h>

%hook SBScreenFlash

-(void)flashColor:(id)color {

NSDictionary *prefs=[[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.junyi00.screenshotcolor.plist"];

if ([[prefs objectForKey:@"enable"] boolValue]){
    color = [UIColor blueColor];
    %orig(color); }
else {
    %orig; }
}

%end