Andy Fedoroff Andy Fedoroff - 1 month ago 10
Swift Question

I get Metadata.framework error when I try to import an image


I've got the following message in Xcode's Debug Area after importing an image in my app:

[21950:1148196] Metadata.framework [Error]: couldn't get the client port.

How can I get rid of this error?


Here's my code for uploading a picture:

@IBAction func importButton(sender: AnyObject) {

let uploadFile: NSOpenPanel = NSOpenPanel()

uploadFile.allowsMultipleSelection = false
uploadFile.canChooseFiles = true
uploadFile.canChooseDirectories = false

uploadFile.runModal()

let chosenPicture = uploadFile.URL

if(chosenPicture != nil) {

let pictureImport = NSImage(contentsOfURL: chosenPicture!)
imageWell.image = pictureImport
}
}

Answer

I get this error message because I have Spotlight indexing disabled (so apps' and images' metadata is inaccessible). After turning Spotlight automatic indexing ON the error message "Metadata.framework [Error]: couldn't get the client port" in Xcode's Debug Area disappears.