Kjuly / ALAssetsLibrary-CustomPhotoAlbum

A nice ALAssetsLibrary category for saving images & videos into custom photo album.
http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/
MIT License
405 stars 101 forks source link

ALAssetsGroup failed to add asset: null on iOS11 #50

Closed Alphts closed 6 years ago

Alphts commented 6 years ago

Hi @Kjuly I am using the latest version of your library but i am facing this issue on IOS 11: ALAssetsGroup failed to add asset: null.I am sure i added the Photos.framework to my Project.I run your ALAssetsLibraryCustomPhotoAlbum_BasicDemo in my iPhone6, and i am also facing this issue.Any help would be great.

Kjuly commented 6 years ago

Several guys reported such issue before, but i haven't met & not able to reproduce yet. Sorry for it. I'll do more checking when got enough time.

Btw, i suggest just use the Photos.framework to handle related feature if ur project deployment target is >= iOS 8. :)

AlucarDWeb commented 6 years ago

I'm having the same issue, on iOS 11.2.2. I've noticed that the issue is not verified while I'm debugging le library. Could this be a multithreading issue?

AlucarDWeb commented 6 years ago

This issue happens if you have iCloud with photos activated, otherwise it won't happen.

Kjuly commented 6 years ago

@AlucarDWeb it's great to know this clue. :+1:

Kjuly commented 6 years ago

Hi guys, I just commit a patch to handle the case that -assetForURL:resultBlock:failureBlock: returns nil asset in resultBlock, though I still can't reproduce at my side (even tried iCloud related setting).

According to the error message, i simulated error case by setting the asset to nil in resultBlock. ;)

geek-paulwong commented 6 years ago

@Kjuly Your solution works well for iOS 11 now. Thank you. Meanwhile, the UI thread seems to be blocked as the asset now is manually compared one by one in the patch. Is there any solution for that?

Kjuly commented 6 years ago

@geek-paulwong yeah, it'll take long time if there're lots photos, u can provide a progress hud for the process. Of course, the best way is to use Photos.framework directly instead.

geek-paulwong commented 6 years ago

@Kjuly Oh, gotcha! Do you know how to save video to custom album with Photos.framework directly? I couldn't find examples like that.

Kjuly commented 6 years ago

@geek-paulwong maybe https://stackoverflow.com/questions/44669178/save-video-to-a-custom-album-using-photos-framework-in-ios will helps, there's a +creationRequestForAssetFromVideoAtFileURL: for class PHAssetChangeRequest. :)

geek-paulwong commented 6 years ago

@Kjuly thank you, it looks legit! ;)