xcode 我在 Objective C 中的调整中未声明的标识符“UIColor”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14814852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:45:18  来源:igfitidea点击:

Undeclared identifier "UIColor" in my tweak in Objective C

objective-cxcodecydiatweak

提问by junyi00

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)

我正在尝试使用 IOSOpenDev 在 Xcode 中进行调整,但是我遇到了一个错误Use of undeclared identifier "UIColor"
我在 iPhone 上使用了相同的代码但它有效,为什么它在这里不起作用?(我想使用 IOSOpenDev 因为它看起来比使用 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

请在这里帮助我

回答by s6luwJ0A3I

You should check if you have

你应该检查你是否有

PROJECTNAME_FRAMEWORKS = UIKit Foundation

Also

#import <UIKit/UIKit.h>

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

在你的tweak.xm(在顶部)像这样

#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