Undeclared identifier "UIColor" in my tweak in Objective C

10,669

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
Share:
10,669
junyi00
Author by

junyi00

Updated on June 15, 2022

Comments

  • junyi00
    junyi00 about 2 years

    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