🧑‍💻/Swift

iOS 18 PHAssetCollection 앨범 불러오기 실패하는 현상

유리맥 2025. 3. 7. 00:14
반응형

PHAssetCollection.fetchAssetCollections()를 사용하여 사진 앱의 앨범을 불러오고 있었는데요.

iOS 18 버전부터 앨범 목록을 fetch 해도 0개로 나오는 이슈가 발생했습니다.

let fetchOptions = PHFetchOptions()
fetchOptions.includeAllBurstAssets = true
fetchOptions.includeAssetSourceTypes = [.typeUserLibrary, .typeCloudShared]
let smartAlbums = PHAssetCollection.fetchAssetCollections(
    with: .album,
    subtype: .smartAlbumVideos,
    options: fetchOptions)

 

iOS 18부터 사진 앱이 대폭 업데이트 되더니 타입도 변경되었나 봅니다.

subtype을 smartAlbumVideos로 제한하고 있었는데 any로 바꿔주니 잘 동작했습니다.

let fetchOptions = PHFetchOptions()
fetchOptions.includeAllBurstAssets = true
fetchOptions.includeAssetSourceTypes = [.typeUserLibrary, .typeCloudShared]
let smartAlbums = PHAssetCollection.fetchAssetCollections(
    with: .album,
    subtype: .any,
    options: fetchOptions)

 

참고

https://developer.apple.com/documentation/photos/phassetcollection/fetchassetcollections(with:subtype:options:)

 

fetchAssetCollections(with:subtype:options:) | Apple Developer Documentation

Retrieves asset collections of the specified type and subtype.

developer.apple.com

 

반응형