ios 未找到 SDWebImage/UIImageView+WebCache.h 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11033793/
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
SDWebImage/UIImageView+WebCache.h file not found
提问by Lizard
I'm trying to use SDWebImage in my iPhone app. I followed the step by step tutorial to install SDWebImage into my Xcode project.
我正在尝试在我的 iPhone 应用程序中使用 SDWebImage。我按照分步教程将 SDWebImage 安装到我的 Xcode 项目中。
When I try to build my app i'm getting the following error:
当我尝试构建我的应用程序时,出现以下错误:
Lexical or Preprocessor Issue
'SDWebImage/UIImageView+WebCache.h' file not found
Can somebody help me solve this issue?
有人可以帮我解决这个问题吗?
回答by AmitP
A much cleaner "install" of SDWebImage would be as follow:
SDWebImage 的更干净的“安装”如下:
- Drag SDWebImage folder from Finder into your Xcode's project
On any .m file where you wish to use it add:
#import "UIImageView+WebCache.h"
(and any other SD component needed)
instead of what you probably did:
#import <SDWebImage/UIImageView+WebCache.h>
- 将 SDWebImage 文件夹从 Finder 拖到您的 Xcode 项目中
在您希望使用它的任何 .m 文件中添加:
#import "UIImageView+WebCache.h"
(以及任何其他需要的 SD 组件)
而不是你可能做的:
#import <SDWebImage/UIImageView+WebCache.h>
this does not require any project header manipulation and will work as is.
这不需要任何项目标题操作,并且将按原样工作。
回答by enagra
It may happen that:
可能会发生以下情况:
Unzipping this framework, the directory name may be the following: "SDWebImage-3.3.framework"
解压这个框架,目录名可能如下:“SDWebImage-3.3.framework”
If you import the project this way, causes the error "framework SDWebImage not found" when compiling.
如果以这种方式导入项目,会导致编译时报错“framework SDWebImage not found”。
You need renaming, deleting "-3.3". Would be: "SDWebImage.framework"
您需要重命名,删除“-3.3”。将是:“SDWebImage.framework”
Forcing the renamed from Xcode, causes a bug that close unexpectedly the IDE. Renames from Finder and add framework again.
强制从 Xcode 重命名,会导致 IDE 意外关闭的错误。从 Finder 重命名并再次添加框架。
I hope it's useful ...
我希望它有用...
回答by user1433391
I would not wish my worst enemy the frustration I had to go through to fix this problem because none of these solutions helped in my particular case. If your project compiled earlier, you came back to it and this error popped out of nowhere, chances are you've moved it to some new directory - so go to Build Settings > Search Paths > under Framework Search Paths delete the outdated path, create a new one and set it to "$(SRCROOT)" (without quotes) and change the default "non-recursive" to "recursive". I hope this spares someone the agony I endured.
我不希望我最大的敌人在解决这个问题时遇到挫折,因为这些解决方案在我的特殊情况下都没有帮助。如果您的项目较早编译,您又回到了它并且这个错误突然出现,很可能您已经将它移动到某个新目录 - 所以去构建设置>搜索路径>在框架搜索路径下删除过时的路径,创建一个新的并将其设置为“$(SRCROOT)”(不带引号)并将默认的“非递归”更改为“递归”。我希望这能让某人免于我忍受的痛苦。
回答by Feroz
Using #import <SDWebImage/UIImageView+WebCache.h>
fixed the issue for me as I was using Cocoapods as frameworks (use_frameworks!).
使用#import <SDWebImage/UIImageView+WebCache.h>
为我解决了这个问题,因为我使用 Cocoapods 作为框架(use_frameworks!)。
回答by Alatoo
I had .xcodeproj and .xcworkspace files and launched the code using .xcodeproj and got this error, but with .xcworkspace it worked fine
我有 .xcodeproj 和 .xcworkspace 文件并使用 .xcodeproj 启动代码并出现此错误,但使用 .xcworkspace 它工作正常
回答by rodchile
The @Lizard answer saved my day!
@Lizard 的回答拯救了我的一天!
$(SRCROOT)/SDWebImage to Header Search Path
$(SRCROOT)/SDWebImage 到标题搜索路径
Just to be more specific, you have to add that configuration in your target and not in the project view.
更具体地说,您必须在目标中而不是在项目视图中添加该配置。
回答by Mann
Use
用
#import "UIImageView+WebCache.h"
instead of
代替
#import <SDWebImage/UIImageView+WebCache.h>
Will solve it.
会解决的。
回答by vishwa.deepak
Check if you have linked the file correctly and its in your bundle or not.
检查您是否已正确链接文件及其在您的包中。
回答by Khawar
I was also getting this problem. Solution for me was to add SDWebImage.framework, instead of adding all files in my project. Here is the check list to make sure everything is setup as suggested by auther here.
我也遇到了这个问题。我的解决方案是添加 SDWebImage.framework,而不是在我的项目中添加所有文件。这是检查清单,以确保一切都按照 auther here 的建议进行设置。
Download and Add framework
下载并添加框架
Step 1: Download and unzip the lastest version here: https://github.com/rs/SDWebImage/wiki/Download-Complied-Framework
第 1 步:在此处下载并解压最新版本:https: //github.com/rs/SDWebImage/wiki/Download-Complied-Framework
Step 2: Right-click on the project navigator and select "Add Files to "Your Project": In the dialog, select SDWebImage.framework, and check the "Copy items into destination group's folder (if needed)" checkbox
第 2 步:右键单击项目导航器并选择“将文件添加到“您的项目”:在对话框中,选择 SDWebImage.framework,并选中“将项目复制到目标组的文件夹(如果需要)”复选框
Add dependencies
添加依赖项
In you application project app's target settings, find the "Build Phases" section and open the "Link Binary With Libraries" block: Click the "+" button again and select the "ImageIO.framework"
在您的应用程序项目应用程序的目标设置中,找到“Build Phases”部分并打开“Link Binary With Libraries”块:再次单击“+”按钮并选择“ImageIO.framework”
Add Linker Flag
添加链接器标志
Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag:
打开“Build Settings”选项卡,在“Linking”部分,找到“Other Linker Flags”设置并添加“-ObjC”标志:
Import headers in your source files
在源文件中导入标头
#import <SDWebImage/UIImageView+WebCache.h>
It should build now without any problem.
现在应该可以正常构建了。
回答by nr5
I got this error when I was removing some old unused Pods while keeping the XCode open. I have seen and read that you must keep XCode closed while doing any pod operation. Once pod operation is done, you should then reopen xcworkspace file and build.
当我在保持 XCode 打开的同时删除一些旧的未使用的 Pod 时,我遇到了这个错误。我已经看到并读到在执行任何 pod 操作时必须保持 XCode 关闭。pod 操作完成后,您应该重新打开 xcworkspace 文件并构建。
Did the same closed the XCode, but also I removed the contents of Derived data just to start from a fresh page. It worked !
同样关闭了 XCode,但我也删除了派生数据的内容只是为了从一个新页面开始。有效 !