Quoc Nguyen is correct. You can just use image literal name. Like so:
private lazy var logoImageView: UIImageView = {
let imageView = UIImageView(image: UIImage(named: "swift_logo"))
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()
The UIImageView initialiser method can take an optional UIImage object:
init(image: UIImage?)
And the UIImage initialiser method using name produces optional UIImage object.
init?(named name: String)
That means, you can use it safely. Regardless if your logo exists or not. I hope this helps!
UPDATE:
You can make your own extension of UIImage class to declare your assets, so that when time comes that you need to rename an asset, you'll have to rename it once and the changes will be applied all throughout your project (globally, as you say).
import UIKit
/// A category for handling images
extension UIImage {
// MARK: - Home Assets
static let swiftLogo = UIImage(named: "swift_logo")
}
and you can use that like so:
private lazy var logoImageView: UIImageView = {
let imageView = UIImageView(image: .swiftLogo)
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()