.process
PROCESS THIS BASED ON PER-PLATFORM
RULES AND OPTIMIZATIONS
Slide 20
Slide 20 text
.copy
Slide 21
Slide 21 text
.copy
COPY THIS EXACTLY AS IT IS
(INCLUDING DIRECTORY STRUCTURE)
Slide 22
Slide 22 text
RESOURCES ARE SCOPED
PER-TARGET
Slide 23
Slide 23 text
No content
Slide 24
Slide 24 text
Bundle.module
Slide 25
Slide 25 text
Bundle.module
THIS IS THE BUNDLE FOR THE CURRENT
MODULE CREATED BY THE SPM TARGET
Slide 26
Slide 26 text
WITHIN YOUR LIBRARY
Bundle.module.url(forResource: self.fileName,
withExtension: self.fileExtension)
UIImage(named: self.fileName,
in: .module,
compatibleWith: nil)
Slide 27
Slide 27 text
WITHIN YOUR LIBRARY
Bundle.module.url(forResource: self.fileName,
withExtension: self.fileExtension)
UIImage(named: self.fileName,
in: .module,
compatibleWith: nil)
Slide 28
Slide 28 text
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)
}
}
Slide 29
Slide 29 text
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)
}
}
BASE.LPROJ
✅
Storyboards and Nibs
"
.strings files
Slide 39
Slide 39 text
USE ISO CODES
English: en.lproj
Slide 40
Slide 40 text
USE ISO CODES
English: en.lproj
!
English: en_GB.lproj
Slide 41
Slide 41 text
USE ISO CODES
English: en.lproj
!
English: en_GB.lproj
"
English: en_US.lproj
Slide 42
Slide 42 text
No content
Slide 43
Slide 43 text
No content
Slide 44
Slide 44 text
"Avoiding unintentionally copying
files not intended to be localized
variants into the product"
Slide 45
Slide 45 text
DON'T COPY RESOURCES FOR
UNSUPPORTED LANGUAGES
Slide 46
Slide 46 text
WHAT CAN'T YOU INCLUDE
USING RESOURCES?
Slide 47
Slide 47 text
THINGS YOU DON'T WANT
INCLUDED IN YOUR LIBRARY
Slide 48
Slide 48 text
BUILD SCRIPTS
IN BASH OR OTHER LANGUAGES
Slide 49
Slide 49 text
No content
Slide 50
Slide 50 text
!
Slide 51
Slide 51 text
OBLIGATORY SUMMARY SLIDE
Slide 52
Slide 52 text
OBLIGATORY SUMMARY SLIDE
> SPM lets you include resources used in your code in a
target like images, core data models, xibs, etc.
Slide 53
Slide 53 text
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
Slide 54
Slide 54 text
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
Slide 55
Slide 55 text
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!
Slide 56
Slide 56 text
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
Slide 57
Slide 57 text
THANK YOU!
Slide 58
Slide 58 text
APPLE LINKS
> https://developer.apple.com/documentation/
swift_packages/
bundling_resources_with_a_swift_package
> https://developer.apple.com/documentation/
swift_packages/
localizing_package_resources