2

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

6
  • 1
    If this is for OSX, then you shouldn't be using UIKit classes, you're probably looking for NSColor
    – Dan F
    Feb 11, 2013 at 15:13
  • After changing to color = [NSColor blueColor]; Now they are telling me Use of undeclared identifier 'NSColor'; did u mean 'NSCoder'?
    – junyi00
    Feb 11, 2013 at 15:18
  • I am not sure what exactly it is you are using to write or compile this code, I don't recognize the % syntax you use. If the compiler can't find NSColor you probably aren't linking the AppKit framework or aren't including AppKit/AppKit.h
    – Dan F
    Feb 11, 2013 at 15:20
  • I'm using xocde since IOSOpenDev is somewhat a plugin for Xcode which allows me to create iPhone tweaks and others just from Xcode
    – junyi00
    Feb 11, 2013 at 15:25
  • If this is for iOS, then UIColor is the class you want, you just need to make sure UIKit framework is linked, and you are #includeing UIKit/UIKit.h
    – Dan F
    Feb 11, 2013 at 15:27

1 Answer 1

6

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.