In moving over to PhotoKit to save photos+metadata from my app, I discovered what I think is a pretty serious bug when associating a file name with the photo. First of all, here is what I am doing:
PHAssetCreationRequest *assetRequest = [PHAssetCreationRequest creationRequestForAsset];
PHAssetResourceCreationOptions *creationOptions = [PHAssetResourceCreationOptions new];
creationOptions.originalFilename = @"mycustomname.jpg";
creationOptions.uniformTypeIdentifier = @"public.jpeg";
creationOptions.shouldMoveFile = YES;
[assetRequest addResourceWithType:PHAssetResourceTypePhoto fileURL:[NSURL fileURLWithPath:imgDataFilePath] options:creationOptions];
This does associate a filename with the asset, but the filename is not recognized in most typical software that can import photos from a device. In fact, the only software that seems to recognize it is Photos on a Mac, and only when the iPhone is tethered to the Mac — if a photo comes across through iCloud PhotoStream, the specified filename is often lost. And PC users or folks using other software to import/sync photos (including image capture on a Mac to a USB-tethered iPhone) will not see the specified filename or even the typical camera roll name like "IMG_1234.JPG" -- they will instead see a random and useless alphanumeric filename like "ABCD1234.JPG".
I submitted a bug report about this (#41787363) but after a couple rounds of communication, the bug was closed. I don't think the folks looking at the bug report really understood the problem or looked at my sample app because they just told me to use the above approach to name a file, which is what I am already doing and is what causes the bug in the first place.
I have a sample app that demonstrates the problem and it can be easily seen using the Image Capture app on a Mac to view photos on a tethered iPhone. Not sure what else I can do about this so I am posting up here in case anyone else runs into the problem. I have seen a couple other reports of this problem elsewhere on the internet so it's affecting other folks.