xcode sdwebimage: UIImageView+WebCache.h: 没有那个文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9042569/
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-14 23:08:07  来源:igfitidea点击:

sdwebimage: UIImageView+WebCache.h: No such file or directory

iphonexcodeimportinstallationsdwebimage

提问by Ravi

I am fairly new to ios development - trying to use sdwebimage in my iphone project. I believe I completed all basic setups as required. But when I build, I get this error: No such file file or directory near this line:

我对 ios 开发还很陌生 - 尝试在我的 iphone 项目中使用 sdwebimage。我相信我已按要求完成了所有基本设置。但是当我构建时,我收到这个错误:在这一行附近没有这样的文件文件或目录:

#import "UIImageView+WebCache.h"
  • Yes I have added Target Dependencies
  • I have added libSDWebImage.a in Link Binary With Libraries
  • I have -all_load -ObjC in Other Linker Flags
  • I also tried the -force_load ${BUILT_PRODUCTS_DIR}/libSDWebImage.a (64bit mac)
  • My Use Header Search Paths is : $(BUILT_PRODUCTS_DIR)
  • I cleaned the project and rebuilt - but no use.
  • 是的,我添加了目标依赖项
  • 我在 Link Binary With Libraries 中添加了 libSDWebImage.a
  • 我在其他链接器标志中有 -all_load -ObjC
  • 我也试过 -force_load ${BUILT_PRODUCTS_DIR}/libSDWebImage.a (64bit mac)
  • 我的使用标题搜索路径是:$(BUILT_PRODUCTS_DIR)
  • 我清理了项目并重建 - 但没有用。

Build keeps failing. Again, XCode4 code completion "resolves" when I type #import "UI & hit "ctrl+space" which means the lib is visible to xcode. Any pointers will be super helpful. Thanks.

构建不断失败。同样,当我输入 #import "UI 并点击 "ctrl+space" 时,XCode4 代码完成“解析”,这意味着该库对 xcode 可见。任何指针都会非常有用。谢谢。

回答by Mike O'Toole

To add the needed header files to the build path do the following.

要将所需的头文件添加到构建路径,请执行以下操作。

  1. Select your project file
  2. Select your target
  3. Select Build settings
  4. In the search box enter 'header search paths'
  5. For the Release add "$(SOURCE_ROOT)/SDWebImage"(thats with quotes).
  1. 选择您的项目文件
  2. 选择你的目标
  3. 选择构建设置
  4. 在搜索框中输入“标题搜索路径”
  5. 对于发布添加"$(SOURCE_ROOT)/SDWebImage"(带引号的)。

This will work when importing like this #import <SDWebImage/UIImageView+WebCache.h>

这将在像这样导入时起作用 #import <SDWebImage/UIImageView+WebCache.h>

回答by otakuProgrammer

I also use SDWebImage.
In my experience I didn't do anything with the linker flags etc.
You only have to add the classes in your project and simply import the "UIImageView+WebCache.h" in your class' header like this:

我也使用SDWebImage
根据我的经验,我没有对链接器标志等做任何事情。
您只需要在项目中添加类,然后在类的标题中简单地导入“UIImageView+WebCache.h”,如下所示:

#import "UIImageView+WebCache.h"

and if you want to use it on an UIImageView object, just use the method

如果你想在 UIImageView 对象上使用它,只需使用该方法

setImageWithURL:placeholderImage:

you can refer to their github for more info

你可以参考他们的github了解更多信息

回答by lionel

I just ran into this problem and have solved it.

我刚刚遇到了这个问题并解决了它。

The issue is that when you "drag" the SDWebImage xcode project to your project, Xcode only create a reference to point to those files needed. When you are in debug mode it's fine, it knows where to find those file. However, when you want to archive it (packing everything to be self-contained), it couldn't find it from your search path.

问题是,当您将 SDWebImage xcode 项目“拖动”到您的项目时,Xcode 只会创建一个指向所需文件的引用。当您处于调试模式时,这很好,它知道在哪里可以找到这些文件。但是,当您想要归档它(将所有内容打包成独立的)时,它无法从您的搜索路径中找到它。

Although you have added $(BUILT_PRODUCTS_DIR) to your search path, but if the actual files that you downloaded are not physically located in your $(BUILT_PRODUCTS_DIR), then Xcode won't find them. This was the problem for me since my SDWebImage files were still sitting in my download folder.

尽管您已将 $(BUILT_PRODUCTS_DIR) 添加到您的搜索路径,但如果您下载的实际文件实际上不在您的 $(BUILT_PRODUCTS_DIR) 中,那么 Xcode 将找不到它们。这对我来说是个问题,因为我的 SDWebImage 文件仍然位于我的下载文件夹中。

What you want to do is:

你想要做的是:

1.Move the SDWebImage folders to a place where you won't accidentally delete it. Notice once you've done that, the SDWebImage project file will become red since it's physical location is moved. And it's wired that I could not delete that reference in Xcode, what I ended up doing is add that file again (choosing from the location where I just move it too). You will end up with a red SDWebImage.xcodeproj in your project navigator which you can not delete. It's very annoying but it won't affect anything. 2. If the location you move the SDWebImage stuff to is not in your $(BUILT_PRODUCTS_DIR), then you either move that inside $(BUILT_PRODUCTS_DIR) or as I do, add the path to Target -> Build Settings -> Search Paths -> User Header Search Paths.

1.将SDWebImage文件夹移动到一个不会被意外删除的地方。请注意,完成此操作后,SDWebImage 项目文件将变为红色,因为它的物理位置已移动。而且我无法在 Xcode 中删除该引用,我最终做的是再次添加该文件(从我刚刚移动它的位置选择)。您最终会在项目导航器中看到一个无法删除的红色 SDWebImage.xcodeproj。这很烦人,但不会影响任何事情。2. 如果您将 SDWebImage 内容移动到的位置不在 $(BUILT_PRODUCTS_DIR) 中,那么您要么将其移动到 $(BUILT_PRODUCTS_DIR) 内,要么像我一样将路径添加到目标 -> 构建设置 -> 搜索路径 ->用户标题搜索路径。

Archive and it should work now.

存档,它现在应该可以工作了。

回答by Damon Aw

I faced this same problem and was about to go crazy. Like Ravi, I followed the static installation instructions as closely as possible.

我遇到了同样的问题,快要疯了。像 Ravi 一样,我尽可能地遵循静态安装说明。

I saw the auto suggest for UIImageView+WebCache.hwhen I was typing #import, but it keeps throwing file not found.

UIImageView+WebCache.h在打字时看到了自动提示#import,但它一直抛出找不到文件。

In the end, it was this. In header search paths,

最后,就是这样。在标题搜索路径中

“$(BUILT_PRODUCTS_DIR)”- Wrong.

“$(BUILT_PRODUCTS_DIR)”- 错误的。

$(BUILT_PRODUCTS_DIR)- Right.

$(BUILT_PRODUCTS_DIR)- 对。

Embarrassed but now it's working right =)

尴尬,但现在它正常工作了 =)

回答by user2335411

I've been dealing with this problem for the past hour and noticed something that hasn't been mentioned: Make sure that when you up update header search paths that the "Recursive" option is selected! Otherwise the compiler will not check subfolders.

过去一个小时我一直在处理这个问题,并注意到一些没有提到的事情:确保在更新标题搜索路径时选择了“递归”选项!否则编译器不会检查子文件夹。

Worked for me...

对我来说有效...

回答by Shashant Dahikar

I was dealing with the same problem, my two frameworks were not getting found. I tried all the suggested ways in order to resolve the error but it couldnt help. Atlast I deleted the frameworks from my project structure and reloaded them from the original project file and it worked!! Please try this if it helps, It worked for me...

我正在处理同样的问题,我的两个框架没有被找到。我尝试了所有建议的方法来解决错误,但无济于事。Atlast 我从我的项目结构中删除了框架并从原始项目文件中重新加载它们并且它工作了!!如果有帮助,请试试这个,它对我有用......

回答by Vineeth Joseph

I had a similar issue after pod update. If you are using CocoaPods version higher than 1.0.0 and more than one target in your project, you have to add all the targets into the Podfile.

pod 更新后我遇到了类似的问题。如果您使用的 CocoaPods 版本高于 1.0.0 并且您的项目中有多个目标,则必须将所有目标添加到 Podfile 中。