Before iOS 13, you would have to create your own machine learning model to implement text recognition. As Martin points out, it's now directly supported in the Vision framework. In this tutorial, he builds a text recognition app with SwiftUI. Besides learning about text recognition, this post is a great way to see the power of SwiftUI.
Text recognition on iOS 13 with Vision, SwiftUI and Combine by Martin Mitrevski