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

Getting Resourceful With Swift Package Manager ...

Getting Resourceful With Swift Package Manager - Swifters Budapest, Online, December 2020

A lightning talk from Swifters Budapest about SPM 5.3's new ability to handle resources.

Kittstagram app: https://github.com/designatednerd/Kittstagram
HankBytes Library: https://github.com/designatednerd/HankBytes
Video: [Coming soon!]

Ellen Shapiro

December 15, 2020
Tweet

More Decks by Ellen Shapiro

Other Decks in Technology

Transcript

  1. GETTING RESOURCEFUL WITH SWIFT PACKAGE MANAGER SWIFTERS BUDAPEST | THE

    INTERNETS | DECEMBER 2020 ELLEN SHAPIRO | @DESIGNATEDNERD | APOLLOGRAPHQL.COM
  2. targets: [ .target( name: "HankBytes", dependencies: [], resources: [ .process("Resources")

    ] ), .testTarget( name: "HankBytesTests", dependencies: ["HankBytes"]), ]
  3. targets: [ .target( name: "HankBytes", dependencies: [], resources: [ .process("Resources")

    ] ), .testTarget( name: "HankBytesTests", dependencies: ["HankBytes"]), ]
  4. PUBLIC API YOUR APP CAN CONSUME public var image: UIImage?

    { if let image = UIImage(named: self.fileName, in: .module, compatibleWith: nil) { return image } else { guard let path = self.photoURL?.path else { return nil } return UIImage(contentsOfFile: path) } }
  5. PUBLIC API YOUR APP CAN CONSUME public var image: UIImage?

    { if let image = UIImage(named: self.fileName, in: .module, compatibleWith: nil) { return image } else { guard let path = self.photoURL?.path else { return nil } return UIImage(contentsOfFile: path) } }
  6. let package = Package( name: "HankBytes", defaultLocalization: "en", platforms: [

    .iOS(.v14) ], products: [ .library( name: "HankBytes", targets: ["HankBytes"]), ], dependencies: [], targets: [...
  7. let package = Package( name: "HankBytes", defaultLocalization: "en", platforms: [

    .iOS(.v14) ], products: [ .library( name: "HankBytes", targets: ["HankBytes"]), ], dependencies: [], targets: [...
  8. !

  9. OBLIGATORY SUMMARY SLIDE > SPM lets you include resources used

    in your code in a target like images, core data models, xibs, etc.
  10. OBLIGATORY SUMMARY SLIDE > SPM lets you include resources used

    in your code in a target like images, core data models, xibs, etc. > Resources are scoped to a particular target
  11. OBLIGATORY SUMMARY SLIDE > SPM lets you include resources used

    in your code in a target like images, core data models, xibs, etc. > Resources are scoped to a particular target > Bundle.module auto-generated when targets declare resources
  12. OBLIGATORY SUMMARY SLIDE > SPM lets you include resources used

    in your code in a target like images, core data models, xibs, etc. > Resources are scoped to a particular target > Bundle.module auto-generated when targets declare resources > Resources can be localized!
  13. OBLIGATORY SUMMARY SLIDE > SPM lets you include resources used

    in your code in a target like images, core data models, xibs, etc. > Resources are scoped to a particular target > Bundle.module auto-generated when targets declare resources > Resources can be localized! > It does not let you include build helpers