I am using the follow code to fetch all smart albums:
PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.smartAlbum, subtype: PHAssetCollectionSub
If you want to exclude the Panoramas, consider using an array and fetching only the collection you need. In other words, whitelisting collections. Or you can enumerate through the collections and exclude the Panoramas. Whitelisting also gives you control of the order of collections.
var smartAlbums: [PHAssetCollection] = []
let subtypes:[PHAssetCollectionSubtype] = [
// all photos collection
// .smartAlbumUserLibrary,
.smartAlbumFavorites,
.smartAlbumPanoramas,
.smartAlbumLivePhotos,
.smartAlbumBursts,
.smartAlbumDepthEffect,
.smartAlbumLongExposures,
.smartAlbumScreenshots,
.smartAlbumSelfPortraits
]
smartAlbums = fetchSmartCollections(with: .smartAlbum, subtypes: subtypes)
private func fetchSmartCollections(with: PHAssetCollectionType, subtypes: [PHAssetCollectionSubtype]) -> [PHAssetCollection] {
var collections:[PHAssetCollection] = []
let options = PHFetchOptions()
options.includeHiddenAssets = false
for subtype in subtypes {
if let collection = PHAssetCollection.fetchAssetCollections(with: with, subtype: subtype, options: options).firstObject {
collections.append(collection)
}
}
return collections
}