Written by Sean Behan on Mon Jun 11th 2018

This code assumes you're using the UIImagePickerController. If not you will need to get an image url another way.

But, If you are using UIImagePickerControllerDelegate then it will supply the asset's url in the info dictionary . From the asset's url you can fetch the asset with PHAsset.fetchAssets method.

Anyway, once you get the array your asset will contain the location.

class ViewController: UIViewController, UIImagePickerControllerDelegate {
  // *** omitted details for implentation of UIImagePickerController *** //

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    if let url = info[UIImagePickerControllerReferenceURL] as? URL {
                if let asset: PHAsset = PHAsset.fetchAssets(withALAssetURLs: [url], options: nil)[0] {
                    print(asset.location ?? "None")
                }
            }           
        dismiss(animated: true, completion:nil) // hide picker when done w/it.
    }
}

Tagged with..
#swift #swift3 #image #assets #gps #location #ios #macos #apple

Just finishing up brewing up some fresh ground comments...