Getting empty result when trying to fetch the output of AVAssetExportSession from PHAsset
<p>I'm attempting to build a small toy iOS app that merges two video assets from the user's photos library. I've gotten to the point where I have merged the videos using an <code>AVMutableComposition</code> instance and now I need to export the composition. I am doing so with the following code:</p>

<pre><code>func saveEditedComposition(_ composition: AVMutableComposition) {
    let documentDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
    let savePath = (documentDirectory as NSString).strings(byAppendingPaths: ["mergeVideo.mov"])[0]
    let url = NSURL(fileURLWithPath: savePath)

    // Set up exporter
    guard let exporter = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetHighestQuality) else { return }
    exporter.outputURL = url as URL
    exporter.outputFileType = AVFileTypeQuickTimeMovie
    exporter.shouldOptimizeForNetworkUse = true

    // Perform the export
    exporter.exportAsynchronously(completionHandler: { () -&gt; Void in
        // Upon completion of the export, 
        DispatchQueue.global().async {
            if exporter.status == .completed {
                let fetchResult = PHAsset.fetchAssets(withALAssetURLs: [exporter.outputURL!], options: nil))
                let phAsset = fetchResult.firstObject! // Crashes here, returning nil.
            }
        }
    })
}
</code></pre>

<p>The problem is, when the completionHandler is run, I am able to see that my exporter has completed without error (<code>if exporter.status == .completed {</code>), but when I try to access the asset at <code>exporter.outputURL</code>, it returns an empty <code>PHFetchResult&lt;PHAsset&gt;</code>. Can anyone see what I'm doing wrong here?</p>