PHAssetExtendedMetadata has the following API:
/// The original file name of this asset.
open var originalFilename: String? { get }
And PHAssetResource has the following API:
@available(iOS, introduced: 9, deprecated: 27, message: "Use filename instead")
open var originalFilename: String { get }
/// The filename associated with this asset resource (if any)
@available(iOS 27, *)
open var filename: String? { get }
I'm confused why PHAssetExtendedMetadata (iOS 27+) has originalFilename while PHAssetResource originalFilename was deprecated and replaced with filename. I would have expected PHAssetExtendedMetadata's property be named filename to match. Are all 3 of these all the exact same name or can there be differences?
The declarations you quoted are accurate. The two originalFilename properties are not two names for one value: one describes a resource, the other describes the asset.
PHAssetResource.originalFilename (https://developer.apple.com/documentation/photos/phassetresource/originalfilename) is documented as "The original filename of the asset resource from when it was created or imported". Its replacement filename (https://developer.apple.com/documentation/photos/phassetresource/filename) is documented as "The filename associated with this asset resource (if any)". Both describe a single resource. PHAssetExtendedMetadata.originalFilename (https://developer.apple.com/documentation/photos/phassetextendedmetadata/originalfilename) is documented as "The original file name of this asset", which describes the asset rather than one of its resources.
That distinction matters because an asset can reference more than one resource. The overview on PHAssetResource (https://developer.apple.com/documentation/photos/phassetresource) states:
Each PHAsset object references one or more resources.
The same overview names three cases:
- A photo asset can contain both JPEG and RAW files representing the same photo.
- A Live Photo asset contains both still photo and video resources.
- An edited asset contains resources representing asset content before and after the edit, as well as a resource corresponding to the PHAdjustmentData object that describes the edit.
assetResources(for:) returns an array for that reason, and PHAssetResourceType (https://developer.apple.com/documentation/photos/phassetresourcetype) names the members. For an asset with several resources there is no single resource filename, so the resource-level values can differ from one another.
The reason for the deprecation is published as well. The PhotoKit section of the iOS and iPadOS 27 release notes (https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-27-release-notes) lists it under Deprecations:
The originalFilename property on PHAssetResource is incorrectly marked as non-nullable, which misrepresents the property value; a new, nullable filename property is available as a replacement. (175412725) (FB22589474)
String becomes String?, so code that reads the deprecated property today will need to handle a nil value, not only a new name.
Nothing published states a relationship between the PHAssetResource properties and PHAssetExtendedMetadata.originalFilename. No such statement appears on the property pages, in the class overviews, or in the release notes. There is no documented basis for treating the three as interchangeable.
PHAssetExtendedMetadata and PHAssetResource.filename both carry the beta banner. Two requests would go to Feedback Assistant (https://developer.apple.com/bug-reporting/) during the beta period: documenting the relationship between the asset-level and resource-level names, and reconsidering the property naming. Posting the Feedback number here helps anyone who finds this thread later.