Is it possible to "hide" a built-in/ predefined .init()?

From SwiftUI:

Image(systemName: String)

This is prone to error with misspelling so I do this:

enum Symbol: String {
    case ellipsisCircle = ""
    case listDash = "list.dash"
    case squareAndPencil = "square.and.pencil"

extension Image {
    init(symbol: Symbol) {
        self.init(systemName: symbol.rawValue)

extension Label where Title == Text, Icon == Image {
    init(_ title: LocalizedStringKey, symbol: Symbol) {
        self.init(title, systemImage: symbol.rawValue)

now I want to only use the new init's I define and make the built-in one unavailable if possible so I'm forced to change all to my new init.

Show a compile error and a fix-it to use the new init.

I'm pretty sure there's no explicit way to block existing inits, in another module's types.

In this specific example (SF Symbols), though, you have other options which might be better anyway: SFSymbolsMacro.

If you need support for Swift prior to 5.9, then… there's at least SFSafeSymbols which doesn't solve your specific problem but saves you having to define enums for the symbols (plus it has all the appropriate @availability annotations so you can be sure you're not using symbols that don't exist on your target OS version(s)).

@young Are you doing it as a one-time job or want it to be permanent? I guess you might patch .swiftinterface files in your copy of SDK, fix all your code, and then restore the SDK (I never tried).

Though it would be a cool feature to force the compiler not to see certain declarations. It's a bit too much challenging for linters, but not so much for the compiler I think .

SFSymbolsMacro is :+1:. So it create an Image in validation to validate the string is a valid name. This is what I need. And I can use my init with the @SFSymbol macro on my enum Symbol.

Is editing the .swiftinterface file actually does something? Aren't these precompile?

How can I edit the file? I search for SwiftUI.swiftinterface and not found.

You can use any text editor you like, it's just a regular text file with Swift code. Actual path to the swiftinterface file depends on your target (platform and architecture). For example SwiftUI module for macos arm64e is located in /Applications/
You can comment out these inits:

@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)
extension SwiftUI.Image {
  // @available(macOS 11.0, *)
  // public init(systemName: Swift.String)

  // public init(systemName: Swift.String, variableValue: Swift.Double?)

Any attempt to use them in client code will result in compilation errors:

import SwiftUI
let i = Image(systemName: "...") // error: Extraneous argument label 'systemName:' in call