As in Cannot invoke initializer for type 'Range<String.Index>' with an argument list of type '(Range<String.Index>)', the compiler error can be fixed by removing the Range<String.Index>(...) conversion. This will still cause warnings
'characters' is deprecated: Please use String or Substring directly
substring(with:)' is deprecated: Please use String slicing subscript.
which can be fixed with
text = prospectiveText[..<prospectiveText.index(prospectiveText.startIndex, offsetBy: maxLength)]
However, you can achieve the same result far simpler with
text = String(prospectiveText.prefix(maxLength))