Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fastlane & SDWebImage

Fastlane & SDWebImage

Mobile Meetup Lille 24/11/2015

Avatar for Digeon Benjamin

Digeon Benjamin

November 24, 2015

More Decks by Digeon Benjamin

Other Decks in Programming

Transcript

  1. Who’s that man ? iOS and Ruby developer. Startup Weekend

    and Hackathon addict. Currently Freelancing Benjamin Digeon @Todiann
  2. Fastlane • iOS Automation for Continuous Delivery • Toolchain with

    lots of separate tools • Save hours of boring work
  3. Toolchain • deliver : Upload screenshots, metadata and your app

    to the App Store • snapshot : Automate taking localized screenshots of your iOS app on every device • frameit : Quickly put your screenshots into the right device frames • PEM : Automatically generate and renew your push notification profiles
  4. Toolchain (2) • sigh : Because you would rather spend

    your time building stuff than fighting provisioning • produce : Create new iOS apps on iTunes Connect and Dev Portal using the command line • cert : Automatically create and maintain iOS code signing certificates • codes : Create promo codes for iOS Apps using the command line
  5. Toolchain (3) • spaceship : Ruby library to access the

    Apple Dev Center and iTunes Connect • pilot : The best way to manage your TestFlight testers and builds from your terminal • boarding : The easiest way to invite your TestFlight beta testers • gym : Building your iOS apps has never been easier
  6. Lanes • A lane define a need • Ruby syntax

    • before_all • after_all • error default_platform :ios platform :ios do before_all do cocoapods #Update pods end desc "Submit a new Beta Build to Apple TestFlight" lane :beta do #... end end
  7. Real World Example lane :beta do cert sigh # Download

    Profivioning profile increment_build_number # Version bumb gym( workspace: "ios.tings.io.xcworkspace", scheme: "ios.tings.io" ) # Build testflight( skip_submission: true ) # Send to Testflight commit_version_bump( message: 'Build Version Bump by fastlane', force: true ) build_number = Actions.lane_context[Actions::SharedValues::BUILD_NUMBER] add_git_tag(tag: "testflight-#{build_number}") push_to_git_remote clean_build_artifacts #Clean end about 80 s (with cocoapods)
  8. Just test it • No more time loss fighting provisioning

    profile • Launch fastlane alpha and go make a coffee • Clean release in my Github project
  9. SDWebImage • An asynchronous image downloader and memory + disk

    image caching • Animated GIF support • WebP format support • A background image decompression • …
  10. Usage [imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; Standard [imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]

    placeholderImage:[UIImage imageNamed:@"placeholder.png"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { ... completion code here ... }]; With completion handler
  11. Using cache directly SDImageCache *imageCache = [[SDImageCache alloc] initWithNamespace:@"myNamespace"]; [imageCache

    queryDiskCacheForKey:myCacheKey done:^(UIImage *image) { // image is not nil if image was found }]; Query cache (lookup the disk cache if an image can't be found in the memory cache) [[SDImageCache sharedImageCache] storeImage:myImage forKey:myCacheKey]; Store image
  12. Why just not use NSURLCache • Because NSURLCache does memory

    and disk caching (since iOS5) of raw HTTP responses • SDWebImage caches the UIImage representation in memory and store the original compressed image file on disk • https://github.com/bpoplauschi/ ImageCachingBenchmark