JJSaccolo / UIActivityIndicator-for-SDWebImage

The easiest way to add a UIActivityView to your SDWebImage view
MIT License
817 stars 161 forks source link

cocoapods / swift and SDWebImage imports #23

Open desseim opened 9 years ago

desseim commented 9 years ago

I tried to install UIActivityIndicator-for-SDWebImage through cocoapods and use it in a Swift project. As far as I checked pod install did its job correctly and UIActivityIndicator-for-SDWebImage links to SDWebImage.framework. In my project I

import SDWebImage
import UIActivityIndicator_for_SDWebImage

but the Swift compiler issues an error trying to build the Objective-C module UIActivityIndicator-for-SDWebImage. That error being it not finding UIImageView+WebCache.h at its import statement in UIImageView+UIActivityIndicatorForSDWebImage.h, which looks like this:

#import "UIImageView+WebCache.h"

I referred to the guide to cocoapods frameworks and after modifying the failing import statements to

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

(SDImageCache.h was failing too) it compiled.

I'm not experienced enough with the iOS toolchain and cocoapods yet to know whether the library files should actually be updated or if something is wrong with my project configuration, so "please advise" :)

Thanks!

desseim commented 9 years ago

By the way this edit in the SDWebImage recommendations seems to support the updating the import statements.

moyoteg commented 8 years ago

Any luck with this? =)

dilizarov commented 8 years ago

@moyoteg I solved the issue by simply changing it from #import "UIImageView+WebCache.h" to #import <SDWebImage/UIImageView+WebCache.h>

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

Should do the trick.

parthibl commented 8 years ago

it works thank you! @dilizarov

Roshanzs commented 8 years ago

good

dzpt commented 8 years ago

I've done my fix like @dilizarov . however there is an error.

'-[UIImageView setImageWithURL:usingActivityIndicatorStyle:]: unrecognized selector sent to instance 0x7a98bb00'
*** First throw call stack:
(
    0   CoreFoundation                      0x0139aa14 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x00711e02 objc_exception_throw + 50
    2   CoreFoundation                      0x013a3d63 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x012e16bd ___forwarding___ + 1037
    4   CoreFoundation                      0x012e128e _CF_forwarding_prep_0 + 14
    5   imeproject                    0x000837c4 _TFC16imeproject14ViewController14collectionViewfS0_FTCSo16UICollectionView22cellForItemAtIndexPathCSo11NSIndexPath_CSo20UICollectionViewCell + 3252
    6   imeproject                    0x00083919 _TToFC16imeproject14ViewController14collectionViewfS0_FTCSo16UICollectionView22cellForItemAtIndexPathCSo11NSIndexPath_CSo20UICollectionViewCell + 89
    7   UIKit                               0x02cbb236 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:] + 448
    8   UIKit                               0x02cbaf78 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 65
    9   UIKit                               0x02cbda6b -[UICollectionView _updateVisibleCellsNow:] + 5136
    10  UIKit                               0x02cc2be2 -[UICollectionView layoutSubviews] + 241
    11  UIKit                               0x02425008 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
    12  libobjc.A.dylib                     0x00726059 -[NSObject performSelector:withObject:] + 70
    13  QuartzCore                          0x0205d80a -[CALayer layoutSublayers] + 144
    14  QuartzCore                          0x020514ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
    15  QuartzCore                          0x02051352 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    16  QuartzCore                          0x02043e8b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
    17  QuartzCore                          0x02077e03 _ZN2CA11Transaction6commitEv + 561
    18  QuartzCore                          0x020786c4 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    19  CoreFoundation                      0x012b3ffe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    20  CoreFoundation                      0x012b3f5e __CFRunLoopDoObservers + 398
    21  CoreFoundation                      0x012a9108 CFRunLoopRunSpecific + 504
    22  CoreFoundation                      0x012a8efb CFRunLoopRunInMode + 123
    23  UIKit                               0x02353206 -[UIApplication _run] + 540
    24  UIKit                               0x02358bfa UIApplicationMain + 160
    25  imeproject                    0x000b78bc main + 140
    26  libdyld.dylib                       0x04d60a21 start + 1
    27  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
aharbavets commented 8 years ago

+1 Swift is the future