Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule Request: Prefer using Asset Symbols #5939

Open
2 tasks done
417-72KI opened this issue Jan 6, 2025 · 0 comments
Open
2 tasks done

Rule Request: Prefer using Asset Symbols #5939

417-72KI opened this issue Jan 6, 2025 · 0 comments
Labels
rule-request Requests for a new rules.

Comments

@417-72KI
Copy link
Contributor

417-72KI commented Jan 6, 2025

New Issue Checklist

New Rule Request

It would be happy when Image that initialized with string replaced with initializer with asset symbols.

  1. Why should this rule be added? Share links to existing discussion about what
    the community thinks about this.

UIKit.UIImage(named:) and SwiftUI.Image(_:) contain the risk of bugs due to typos.
Since Xcode 15, Xcode generates codes for images in the Asset Catalog and it can avoid typos. (ref)

  1. Provide several examples of what would and wouldn't trigger violations.

Would trigger:

// UIKit
UIImage(named: "some_image") // simple
UIImage(named: "some image")  // contains space
UIImage(named: "someImage", in: .module) // contains specified module

// SwiftUI
Image("some_image") // simple
Image("some image")  // contains space
Image("someImage", bundle: .module) // contains specified module

Would not trigger:

// UIKit
UIImage(resource: .someImage)
UIImage(systemName: "trash")  // using SF Symbols

// SwiftUI
Image(.someImage)
Image(systemName: "trash")  // using SF Symbols
  1. Should the rule be configurable, if so what parameters should be configurable?

Currently no.

  1. Should the rule be opt-in or enabled by default? Why?
    See README.md for guidelines on when to mark a rule as opt-in.

Enabled by default on Swift 5.9+.
Asset symbol generation is enabled by default in Xcode, and it needs editing the build setting to disable it.

@SimplyDanny SimplyDanny added the rule-request Requests for a new rules. label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule-request Requests for a new rules.
Projects
None yet
Development

No branches or pull requests

2 participants