Latest 0.0.2
Homepage https://github.com/sorawitt/SunWuKong
License MIT MIT License

Copyright (c) 2018 Sorawit Trutsat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Platforms ios 9.0, requires ARC
Dependencies Firebase/Core, Firebase/Storage
Authors

SunWuKong is a pure-Swift library for downloading and caching images from the Firebase Storage and URL. This project is heavily inspired by the popular FirebaseStorageCahce and MapleBacon .

Version
License
Platform

Requirements

Swift 4

iOS 9.0+

Xcode 9+

This project assumes that you have already setup Firebase for iOS.

Installation

SunWuKong is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'SunWuKong'

Usage

UIImageView

  • With Storage Reference
    let ref: StorageReference = ....
    imageView.wk_setImage(with: ref)
  • With placeholder, progress and completion handler
    
    func setImageWithStorageReference() {
    let ref: StorageReference =  ....
    imageView.wk_setImage(with: ref, placeholder: UIImage(named: "placeholder"), progress: { received, total in
    // Report progress
    }, completion: { [weak self] image in
    // Do something else with the image
    })

}


- With URL
```swift
let url: URL = ....
imageView.wk_setImage(with: url)
  • With placeholder, progress and completion handler
func setImageWithURL() {
  let url: URL = ....
  imageView.wk_setImage(with: url, placeholder: UIImage(named: "placeholder"), progress: { received, total in
    // Report progress
  }, completion: { [weak self] image in
    // Do something else with the image
  })

}

Use the default shared cache

let ref: StorageReference = ...
SunWuKong.shared.image(with: ref) { [weak self] image in
  // do something with your image
}

Create custom storage caches

let oneDaySeconds: TimeInterval = 60 * 60 * 24
let oneDayCache = DiskCache(name: "customCache", cacheDuration: oneDaySeconds)
let wukongCache = SunWuKong(cache: oneDayCache)

Cleaning/pruning the cache

In the didFinishLaunchingWithOptions of your AppDelegate, you should call the prune()
method of your disk caches to remove any old files:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    FirebaseApp.configure()
    SunWuKong.shared.prune()
    return true
}

Author

WuKong, [email protected]

License

SunWuKong is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SunWuKong",
    "platforms": {
        "ios": "9.0"
    },
    "summary": "SunWuKong is a pure-Swift library for downloading and caching images from the Firebase Storage and URL.",
    "requires_arc": true,
    "swift_version": "4.0",
    "version": "0.0.2",
    "license": {
        "type": "MIT",
        "text": "    MIT LicensennCopyright (c) 2018 Sorawit TrutsatnnPermission is hereby granted, free of charge, to any person obtaining a copynof this software and associated documentation files (the "Software"), to dealnin the Software without restriction, including without limitation the rightsnto use, copy, modify, merge, publish, distribute, sublicense, and/or sellncopies of the Software, and to permit persons to whom the Software isnfurnished to do so, subject to the following conditions:nnThe above copyright notice and this permission notice shall be included in allncopies or substantial portions of the Software.nnTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORnIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEnAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERnLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THEnSOFTWARE.n"
    },
    "authors": {
        "WuKong": "[email protected]"
    },
    "homepage": "https://github.com/sorawitt/SunWuKong",
    "source": {
        "git": "https://github.com/sorawitt/SunWuKong.git",
        "tag": "0.0.2"
    },
    "static_framework": true,
    "dependencies": {
        "Firebase/Core": [],
        "Firebase/Storage": []
    },
    "source_files": "SunWuKong/*"
}

Pin It on Pinterest

Share This