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

rocky
  • 3,521
  • 1
  • 23
  • 31
junyi00
  • 792
  • 3
  • 8
  • 28
  • 1
    If this is for OSX, then you shouldn't be using `UIKit` classes, you're probably looking for `NSColor` – Dan F Feb 11 '13 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 '13 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 '13 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 '13 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 `#include`ing `UIKit/UIKit.h` – Dan F Feb 11 '13 at 15:27
  • I tried including `AppKit/AppKit.h` but they give me `'AppKit.h' file not found` error :( – junyi00 Feb 11 '13 at 15:31

1 Answers1

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
s6luwJ0A3I
  • 1,023
  • 1
  • 9
  • 22