| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This plugin lets you automatically rewrite UIKit/SwiftUI image and colour instantations from unreliable string-based inits such as:
UIImage(named: "some icon")
Image("some icon")
UIColor(named: "light blue green")
Color("light blue green")into ImageResource and ColorResource literals (as introduced in Xcode 15) such as:
UIImage(resource: .someIcon)
Image(.someIcon)
UIColor(resource: .lightBlueGreen)
Color(.lightBlueGreen)dependencies: [
.package(url: "https://github.com/idrougge/ResourceRewriterForXcode.git", branch: "main"),
]After a rebuild, a secondary click on your project (or package) in the Project Navigator brings up a menu where you will now find the options "Rewrite image resource strings" and "Rewrite colour resource strings". Select that option and the target where you want your asset references to be fixed up.
As the UIImage(named:) init returns an optional and UIImage(resource:) does not, you may now have if let, guard let or nil coalescing (??) statements that are no longer necessary. These you will have to fix up by yourself as it is beyond the capabilities of a simple plugin.
If you have turned off generated asset symbols, go into your build settings and enable Generate Asset Symbols (ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOLS) or the resource names will not resolve.
After you are done, you are free to remove this dependency again, possibly introducing a linter rule forbidding calls to string-based asset inits.
| Back | FazBrowse Home | New Git URL |