How to install SDWebImage

16,403

Solution 1

When you add the SDWebImage folder in your project then select following option. To add copy of your folder to the destination project and Create groups.

and then you have to write just like

#import "UIImageView+WebCache.h"

And make sure that you are adding to all the targets that you want to use that library.

enter image description here

Documentation at Github :

Add the SDWebImage project to your project

  • Download and unzip the last version of the framework from the download page
  • Right-click on the project navigator and select "Add Files to "Your Project":
  • In the dialog, select SDWebImage.framework:
  • Check the "Copy items into destination group's folder (if needed)" checkbox

Or you can use cocoa pods as other answer suggested.

EDIT : EXAMPLE :

[self.imageView sd_setImageWithURL:[NSURL URLWithString:"yoururl.png"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

Solution 2

You can use CocoaPods to manage libraries in your project.

To add SDWebImage to your project you should add this line to your pod file:

pod 'SDWebImage', '~>3.7'

UPD

To use CocoaPods, you should install it, to create it you can open Terminal and copy/paste this line:

  sudo gem install cocoapods

On next step you should create Podfile in directory that contain your project file. Pods it is text file (you can create it by using xCode or other text editor (only do not use Writer, it uses not correct character for " ' ")).

After you've created Podfile, you should run in Terminal next line:

pod update

It command'll create a workspace file, this file you'll use to open your project. All instructions present on the home page of CocoaPods.

Share:
16,403
Kitcc
Author by

Kitcc

Updated on June 04, 2022

Comments

  • Kitcc
    Kitcc over 1 year

    I need to manage photos in my app and have read much about SDWebImage framework which seems to be the best way to go. However I am finding it incredibly difficult to install. I dont know Ruby and have never used a podfile, so am installing it by downloading the latest SDWebImagefolder & framework and adding them to my project. However when I try to import into my viewcontroller using the suggested imports:

    #import <SDWebImage/UIImageView+WebCache.h>
    #import "UIImageView+WebCache.h"
    

    I get a file not found with on the #import then if I change this to "SDWebImage/UIImageView+WebCache.h" as suggested I get a file not found on the: #import UIImageView+WebCache.h even though I can clearly see it when I open the SDWebImage folder in my project! I'm guessing that these errors also lead to a not found error when I try to use the sd_setImageWithUrl method.

    Here's a screen shot of my project:

    enter image description here

    I hope I can get some help with this as the framework looks to have very good functionality. Any help very much appreciated. Thanks

  • Kitcc
    Kitcc about 8 years
    Thanks IAshish that has solved the import, however I still get the "no visable @interface for'UIImage' declares the selector 'sd_setImageWithURL placeholder image" error on my sd_setImageWithUrl line ........... [photoImageView.image sd_setImageWithURL:url placeholderImage: [UIImage imageNamed:@"placeholder1"]];
  • Kitcc
    Kitcc about 8 years
    Could you let me know how to open my pod file and add this line? I did download a starting Cocoapods tutorial but that was full of Ruby and I wasn;t able to understand what was required at all.
  • Ashish Kakkad
    Ashish Kakkad about 8 years
    try photoImageView sd_setImageWithURL not the photoImageView.imgae !! @Kitcc
  • Nat
    Nat about 8 years
    @Kitcc The same explanation but with more details: stackoverflow.com/a/32295123/849616
  • Developer
    Developer over 7 years
    I already have pod file for AFNetworking so do I need to create separate POD file for SDWebImage or I can write --------------pod 'SDWebImage', '~>3.7'----------------------in the existing pod file?
  • Andrew Romanov
    Andrew Romanov over 7 years
    You should use one Pod file per one project (See CocoaPods home page, tab Get Started).
  • software evolved
    software evolved over 5 years
    I wish you had actually added instructions instead of high-level directives, for those of us who don't have a background in Cocoapods. These instructions are not helpful.