iOS16: localIdentifier of PHAsset gets changed after saving to camera roll

Environment: iOS 16 beta 2, beta 3. iPhone 11 Pro, 12 mini

Steps to reproduce:

  1. Subscribe to Photo Library changes via PHPhotoLibraryChangeObserver, put some logs to track inserted/deleted objects:
func photoLibraryDidChange(_ changeInstance: PHChange) {

	if let changeDetails = changes.changeDetails(for: allPhotosFetchResult) {

	    for insertion in changeDetails.insertedObjects {
	        print("🥶 INSERTED: ", insertion.localIdentifier)
	    }
	    
	    for deletion in changeDetails.removedObjects {
	        print("🥶 DELETED: ", deletion.localIdentifier)
	    }
	}
}
  1. Save a photo to camera roll with PHAssetCreationRequest
  2. Go to the Photo Library, delete the newly saved photo
  3. Come back to the app and watch the logs:
🥶 INSERTED:  903933C3-7B83-4212-8DF1-37C2AD3A923D/L0/001
🥶 DELETED:  39F673E7-C5AC-422C-8BAA-1BF865120BBF/L0/001

Expected result: localIdentifier of the saved and deleted asset is the same string in both logs.

In fact: It's different.

So it appears that either the localIdentifier of an asset gets changed after successful saving, or it's a bug in the Photos framework in iOS 16. I've checked - in iOS 15 it works fine (IDs in logs match).

Post not yet marked as solved Up vote post of popov_v_d Down vote post of popov_v_d
1.3k views

Replies

Any updates on this?

same issue experienced here, on iOS16 but also iOS17 and different device models.

On one device (iPhone13 mini, iOS 16.0.2) it's happening quite frequently and I can confirm the local identifier returned after the deletion in Gallery is different from the original one, as reported here.

Are there any news on this?