R.swift
R.swift copied to clipboard
Bundle resources support
Hi!
Please review/check this implementation of bundle resources support.
Only following types of resources are enabled for now: image
, string
, color
, file
, I've tested them as I could.
font
support won't work, I think we need to use the following technique to register fonts: https://stackoverflow.com/a/40749435/299063
nib
, segue
and storyboard
probably will work, but I didn't test it as I don't have a project using them near me now. If someone could test it, it would be nice.
reuseIdentifier
- probably will work, not sure, needs testing.
entitlements
, info
— I guess we don't need these for bundles
id
- not sure, needs testing.
Note: to test not enabled features, you need to enable them in RswiftCore.swift:run()
(search for supportedGenerators
)
Note 2: because bundle may fail to load at runtime, updated R.swift.Library is needed (where all Bundle references are changed to optional), here is corresponding PR: https://github.com/mac-cain13/R.swift.Library/pull/42
Other way could be force unwrap Bundle instance (in R.bundle.<foo>.bundle
property), then no changes are needed in R.swift.Library. But I guess it is not right way to do as it could lead to crash if bundle is missing in runtime.
Note 3: I noticed that for color generation on watchOS an API without bundle support is used (UIColor(named:)
), however I see that UIColor(named:in:compatibleWith:)
is supported on watchOS 4.0+. I guess there are issues with it about which I am not aware. So I removed bundle color generation for watchOS for now.
@CaioSym Added fixes!
What is the function that this PR can achieve, please? Can you briefly describe it?