try
Attempts to execute some code and might throw an exception.
try!
Attempts to execute some code and crashes your program if it fails.
try?
Attempts to execute some code and returns nil if the call failed.

try Attempts to execute some code and might throw an exception

import Foundation
      
do {
  let snippet = try String(contentsOfFile: "non-existent-file.txt")
}
catch {
  print("Failed to load file.")
}
Output:
Failed to load file.

try! Attempts to execute some code and crashes your program if it fails

import Foundation
      
let snippet = try! String(contentsOfFile: "non-existent-file.txt")
Output:
fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The file “non-existent-file.txt” couldn’t be opened because there is no such file."

try? Attempts to execute some code and returns nil if the call failed

import Foundation
      
let snippet = try? String(contentsOfFile: "non-existent-file.txt")
      
print("snippet = \(snippet)")
Output:
snippet = nil

Note that the purpose of the import Foundation code in the examples is only because of String(contentsOfFile: String). If you do not import it, your code won't compile.