Import ML Kit dependencies on iOS

Viewed 598

I'm following this documentation to implement ML Kit for iOS, but I can't figure out which import should I use to create a VisionImage.

The pod I am using is GoogleMLKit/BarcodeScanning.

I have tried with the following imports without luck:

import MLImage
import MLKit
import MLKitBarcodeScanning

Which is the right import to create a VisionImage and then a BarcodeScanner?

2 Answers

According to MLKit Release Notes (as of June 29, 2021), the correct pod artifact names are listed like this. enter image description here


Update your pod declaration to the latest version like this.

pod 'MLKitBarcodeScanning', '1.3.0'

After this change, do a pod install and now you can use following two imports to work with MLKit on iOS.

import MLKitBarcodeScanning
import MLKitVision

At top of the documentation you referenced, there is a link to the ML Kit quickstart sample, where you can find sample code in both Swift and Objective-C showing you how to import ML Kit. Specifically, in Swift you can import MLKit and in Objective-C @import MLKit;.

Related