Q:

"Instance member 'makeAlert' cannot be used on type 'alert' " I can't fix this error

I created a new swift file and class.  I want to use alert function all of my viewcontrollers.  But I have an error.  Here this is my class and function. 
class alert {

func makeAlert(titleInput:String, messageInput:String){
       let alert = UIAlertController(title: titleInput, message: messageInput, preferredStyle: UIAlertController.Style.alert)
       let okButton = UIAlertAction(title: "Ok", style: UIAlertAction.Style.default, handler: nil)
       alert.addAction(okButton)
   }

}

I want to use my function here like this. 
alert.makeAlert(titleInput: "Error", messageInput: " name or Location can't be empty")

And here my error message:
Instance member 'makeAlert' cannot be used on type 'alert'; did you mean to use a value of this type instead? 

A:

alert is a type and makeAlert is an instance member.  As the error says

Instance member 'makeAlert' cannot be used on type 'alert'

To show the options let me first rename some terms of the code to avoid confusion
class Alert {

   func makeAlert(titleInput: String, messageInput: String) {
       let alertController = UIAlertController(title: titleInput, message: messageInput, preferredStyle: UIAlertController.Style.alert)
       let okButton = UIAlertAction(title: "Ok", style: .default, handler: nil)
       alertController.addAction(okButton)
   }
}

Either create an instance of Alert
let alert = Alert()
alert.makeAlert(titleInput: "Foo", messageInput: "Bar")

or make makeAlert a static function
static func makeAlert(titleInput:String, messageInput:String) { ...

then you can use 'makeAlert' on the type
Alert.makeAlert(titleInput: "Foo", messageInput: "Bar")

For more information please read Methods in the Language Guide

But an extra Alert class is not very useful and also the fact that the function doesn't have a return value.  A better solution is an extension of UIViewController because you are able to present the alert controller in the current view controller
extension UIViewController {
    func presentAlert(title: String, message: String, completion: (() -> Void)?  = nil) {
       let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
       let okButton = UIAlertAction(title: "Ok", style: .default, handler: nil)
       alertController.addAction(okButton)
       self.present(alertController, animated: true, completion: completion)
    }
}
       
 

