R.swift icon indicating copy to clipboard operation
R.swift copied to clipboard

Bundle resources support

Open ivanzoid opened this issue 3 years ago • 2 comments

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.

ivanzoid avatar May 28 '21 10:05 ivanzoid

@CaioSym Added fixes!

ivanzoid avatar Jun 11 '21 12:06 ivanzoid

What is the function that this PR can achieve, please? Can you briefly describe it?

rakuyoMo avatar Feb 28 '22 03:02 rakuyoMo