How to install SDWebImage - ios

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:
I hope I can get some help with this as the framework looks to have very good functionality. Any help very much appreciated. Thanks

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.
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"]];

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.

I ran into this issue recently, and a less intrusive way to fix this problem is to add an entry to your Header Search Paths (all 3 instances) with the content ./SDWebImage/ (assuming that's where the framework is) so that it considers that folder when looking for includes.

I think you have to use a Cocoa Pod file for SDWebImage Library.
init the pod file.
install Pod file.
and then update that pod file.
platform :ios, '7.0'
source 'https://github.com/CocoaPods/Specs.git'
pod 'SDWebImage','3.7.1'
pod 'UIActivityIndicator-for-SDWebImage'
And then you can import the following file.
#import "UIImageView+UIActivityIndicatorForSDWebImage.h"

Related

Import class from development pods with CocoaPods

I get a little older project from another developer and I should fix some issues and add new features. The project is mainly written in ObjC and is using CocoaPods as dependency manager. Previous developer create his own pod in Development Pods and it contains mainly business logic for application. So I needed add some classes there like RCZMortgage. But when I try to use it in main project I get problem:
'RCZMortgage.h' file not found
So I was thinking that I must update pod. So I use command update pod for that one development pod but after that I started have problem with Bridging-Header.h and that files in there can't be found (I don't know if update fix previous problem or just bring more). Previous developer start creating a few classes in swift.
Bridging-Header.h looks like this:
#import "RCZAdvertisementBadge.h"
#import "UIView+Centering.h"
#import "UIColor+CustomColors.h"
#import "UIView+Sizing.h"
#import "SDWebImageManager+AutoScale.h"
#import <SDWebImageManager.h>
#import "RCZImageUrlBuilder.h"
In podfile there is:
platform :ios, '7.0'
but there isn't use_frameworks!
I'm not sure which informations you need to help me. What files should I write here to help me. So any comments and answers are welcome. I can't contact previous developer so I am asking here.
Check weather pod dependencies are correctly matched in build settings.
Give correct pod path, clean the code and try once more.
you should check this tutorial for pod file How to Use CocoaPods
Hope this will help you.

How to get cocoa pods to work?

I have installed cocoapods. I've done everything that I've seen online, yet I can never successfully import a 3rd party framework into my project. I have tried many, many times--at least 20 probably, and have not once been able to successfully do this. Take for example, this library: https://github.com/uacaps/PageMenu
I added the podfile, I ran "pod install", that worked, I opened up the workspace and not the original project, I added the framework under "linked frameworks and libraries." But it still says "No such module Page Menu." It does this for every single pod that I try to install. What am I doing wrong? From what I've read everyone seems to think they are so easy to install. And they are, problem is they just never work once I do install them. Is there some missing step that everyone else knows about that I don't? I have looked under build settings and I've read something about changing the linker flags, but I couldn't figure out how to do that. I have tried installing the library manually and that didn't work either. Could it be that something is just wrong with my Xcode? I've been having this problem for a few months, and it has stayed consistent since I updated my Xcode recently. Does anyone have any idea what this could be?
edit: link to Podfile photo:
http://i58.tinypic.com/2lc2zqb.png
First,make sure that you have something like this in your PodFile (same folder as your xcode proj)
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'PageMenu'
then cd to the directory and do pod install in terminal.
I am assuming that you are using swift. Build the project. Go to your report navigator.
EDIT:: Do open the proj using xcworkspace instead of xcodeproj
You should see something like this.
This tells you what you have to add in your bridging header.
To create a bridging header, create a random objective c file (with cocoa touch class). XCode will ask you if you want to create bridging header.
Select yes, then delete the files you just created. Next, go to the generated bridging header file. Add in
// this header should be based on the name you see in report navigator.
#import <PageMenu/PageMenu-Swift.h>
Look, Calm Down..
I had the same problem.Didnt give up.try doing this as well,worked for me
create new project
close xcode
go to target folder pop init
open -a Xcode Podfile-uncomment platform -pod 'PageMenu' ( I typed this outside target this time/not like the usual way typing it inside target- do/ ,save and close)
open xcodeworkspace and Type - import PageMenu -( still says unresolved module )
Now Build ..
(worked for me, It somehow works with clean or Build i suppose ,so try both)

CocoaPods not building target for Crittercism

I added pod 'CrittercismSDK' to my Podfile and ran pod install, it finished with no error, all good.
Using import Crittercism gives No such module error. I looked into the Pods/ directory, there source code is there; however, the Pods project doesn't have a target called Pods-MyProject-Crittercism (but it does have targets for each dependency).
Build keeps failing because the import isn't found. What am I doing wrong?
PS: I'm using use_frameworks! directive in my Podfile, and I have another obj-c library that works fine, so I don't know why this one isn't working.
While this is not a general answer, I have found that:
Not using #use_frameworks
Using a Bridging-Header.h containing #import "Crittercism.h"
Not importing CrittercismSDK in the Swift class, but merely executing Crittercism.enableWithAppID("appId") does the trick.
See if below steps helps in your case. What version of pod/Xcode in use? It will be great if you can share your pod file, thanks.
Install dependencies using Cocoapods and the use_frameworks! flag.
As you need to use a Objective-C dependency, create a Bridging header. You can create one easily by importing an Objective-C class to your Swift project, than remove it (the wizard should ask you if need a bridging header). Otherwise, create a new header file. Then, navigate to your target configuration and enter the name of your file in Swift Compiler - Code Generation > Objective-C Bridging header.
Still in your target configuration, add a new entry in Search Paths > User Header Search Paths: Pods as value and flag it as recursive.
Remove any import instruction from your code, relative to your Objective-C library.
Build your project. You should have a success.

Xcode can't see objects added via Cocoapods

I have a podfile defined with the following pods.
platform :ios, '8.0'
use_frameworks!
target 'LifeStream' do
pod 'SSKeychain'
pod 'LiveSDK'
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'swift-2.0'
end
I installed the pods and opened up my workspace. I have found that any usage of Alamofire works fine, due to the Swift 2 version of it importing the project as a framework.
When I try to use SSKeychain classes however, I receive a
Use of unresolved identifier 'SSKeychain`
Same applies with any class I try to use in the LiveSDK.
I have a bridge header in my projects root directory, and the project is configured to use it.
#ifndef Header_h
#define Header_h
#import "SSKeychain/SSKeychain.h"
#import "LiveSDK/LiveConnectClient.h"
#endif /* Header_h */
if I change the #import from
#import "SSKeychain/SSKeychain.h"
to
#import "SSKeychain.h"
Xcode fails to compile because it can't find the file. So I assume that the bridge header is working, as the way my bridge header is built now does not generate any compiler errors caused by not finding the headers.
Bridge Header
Framework Search Paths
I have also added my project root directory to the framework search path.
Linked Frameworks
Lastly I have linked all of the frameworks to the project as well.
Am I missing something with my setup? I have not been able to get Cocoapods to work on my project for nearly a week now. I even created a brand new project thinking that mine was just messed up; which didn't change a thing. I don't know what to do from here in order to resolve this.
Edit
After doing some additional research, I found a blog post showing that you have to include your Pods directory in the User Header Search
A commenter also mentioned that if you are using the newer Cocoapods Frameworks support for Swift, then it will need to include the Frameworks/** search path. I've included both Pods/** and Frameworks/** but still have the same issue.
After some further reading, it's beginning to sound like this is a limitation of Cocoapods. From what I understand, you can't use libraries and frameworks together at the same time in a project.
Once you use use_frameworks! in your Podfile, Objective-C Pods like SSKeychain also get build as frameworks.
The actual problem is that only module imports work in the bridging header when using frameworks. Also, you might want to get rid of the bridging header entirely, as it is unnecessary when using frameworks, they can be imported directly in Swift.
To clarify what you should do to make it work:
Be sure to have use_frameworks! in your Podfile
It doesn't matter if you have a Bridging header or not. Leave it untouched
In your SWIFT file just use import Podname
That's it, you're good to go. Of course it may happen that you need to clean your project or maybe delete the derived data folder. Build and you can use it.
If you're not using any swift pods,
Try removing the use_frameworks! on your Podfile.
Run pod install on terminal.
Clean & Build !
I spent almost half an hour fixing it, I tried adding those paths on Search Paths or re-adding the bridging-header but the error was the same.
Therefore, in my case, bridging header file was not the problem, its on the Podfile .
I hope it helps!

"No such module 'Alamofire'" won't recognize framework

I am trying to add Alamofire to a new XCode project with Swift. I feel like I have tried everything.
Every time I try to add
import Alamofire
I get "No such module".
I have tried installing it as stated on https://github.com/Alamofire/Alamofire,
I tried doing it manually first, then Carthage and Cocoapods, but with the same result.
I have tried deleting the DerivedData folder and rebuilding the project without any luck.
It is a completely clean install, yet it just won't recognize the framework. I have tried the suggestions in the first 10 Google searches and here on Stackoverflow (Cannot install Alamofire in new Xcode Project. "No Such module Alamofire") Here are some screenshots from my latest manual attemp:
Looks like you are using the module by directly dropping the source files into your project.
If that's the case, you don't have to use import Alamofire header or use Alamofire( dot ) in the beginning of every method.
Just use the code as below omitting Alamofire tag.
request(.GET, "https://httpbin.org/get")
I know it's late answer, but I was facing same problem with Xcode 8 Swift 3.0. I follow this Alamofire link and added framework manually. Its working fine. One of my project stuck on 'no such module' error, I cleaned derived data (Cleaning derived data removed source files of Alamofire. I added it again in my project ;) ) and it works like charm :).
Followed instructions
Download Alamofire
Drag Alamofire project in your project directory
Check alamofire deployment target same as your project
Go to your project general settings, click on the + button under the "Embedded Binaries" section.
You will see two different Alamofire.xcodeproj folders each with two different versions of the Alamofire.framework nested inside a Products folder. It does not matter which Products folder you choose from, but it does matter whether you choose the top or bottom Alamofire.framework.
Select the top Alamofire.framework for iOS and the bottom one for OS X.
And that's it! The Alamofire.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
same error here.
I solved the problem by the following steps:
Click on your project (targets)
Click on Build Settings
Under Search Paths-Framework Search Paths, add the directory path which contains Alamofire.framework
Hope this can solve your problem!
I was importing Alamofire and I ran into the same issue. Turns out the Cartfile was not in the same folder as the .xcodeproj file.
Once I moved the Cartfile, the Cartfile.resolved files and the Carthage folder to the same folder as the .xcodeproj file my project didn't trigger any errors.
Make sure to also add this line to Build Settings > Framework Search Paths:
$(PROJECT_DIR)/Carthage/Build/iOS
I was able to resolve this issue changing my Podfile. I originally had the reference to Alamofire in a target:
The problem disappeared when I changed the podfile to the following:
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 3.0'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
target 'xxxxxxx' do
pod 'GoogleMaps'
end
target 'xxxxxxxTests' do
pod 'GoogleMaps'
end

Resources