For a PHAsset in the same Photos library on the same device/Mac, what are the documented stability guarantees of PHObject.localIdentifier? Is it safe to persist and use for future PhotoKit operations in that same local library? Are there known cases where it can change or stop resolving?
If a persisted localIdentifier no longer resolves but a persisted PHCloudIdentifier.archivalStringValue does resolve in the same library, is updating the stored local identifier from that cloud mapping the recommended recovery path?
Thanks!
The PHObject.localIdentifier should not be considered for long-term persistence. These identifiers can change in the photo library under certain conditions.
PHCloudIdentifier is the only type that is guaranteed to be consistent through all scenarios and one you should use if you wish to persist asset identifiers.
If you need to maintain the localIdentifier, then you would effectively need to maintain the pair of identifiers and refer back to the PHCloudIdentifier when the PHObject.localIdentifier is no longer valid.
See the snippet example in https://developer.apple.com/documentation/photos/phcloudidentifier on how to handle missing localIdentifiers.