This is an old thread, but updating for anybody who comes across it.
This is a bug in PHPhotoLibrary.
In our app, a small subset of users' devices saw success in PHPhotoLibrary.performChanges but the operation did not work (zero assets were saved).
We could not reproduce it no matter what we tried. Finally, we did manage to reproduce by changing the Photo Library Access setting.
Our test devices' Photo Library permission was "Add Only" (default requirement in our app).
Changing the permission to "Limited Access" did the trick. We reproduced the same result (iOS 18.5):
let urls = [URL]() // empty array to trigger error
PHPhotoLibrary.shared().performChanges({
for url in urls {
let req = PHAssetCreationRequest.forAsset()
req.addResource(with: .photo, fileURL: url, options: nil)
}
}) { success, error in
print(success) // true
}
When "Add Only" is selected, success is false.
I've filed a bug report with Apple.
Topic:
Media Technologies
SubTopic:
Photos & Camera
Tags: