Accessing photos in iOS using phPhotoLibraryMBS

I’m trying to access photos in iOS devices using the phPhotoLibraryMBS.
I have copied most of the functionality in MBS’s Photos demo app into an iOS app but it is not fetching a collection. The same code seems to work fine on OSX.

This is the code that behaves differently:

Dim mediaType As Integer  = 1 //image
Dim phType As Integer = PHAssetCollectionMBS.TypeAlbum  //1
Dim phSubType As Integer = PHAssetCollectionMBS.SubtypeAny  //-1

Dim options As PHFetchOptionsMBS

Dim fetchResult As PHFetchResultMBS = PHAssetCollectionMBS.fetchAssetCollectionsWithType(phType, PHsubType, options)

assetCount = 0
fileCount = 0

For i As Integer = 0  To fetchResult.countOfAssetsWithMediaType(mediaTYpe)  - 1
  Dim v As Variant = fetchResult.objectAtIndex(i)


The app confirms that phPhtoLibraryMBS.authorisationStatus is authorised and plist includes the NSPhotoLibraryUsageDescription.

What happens with the above code is that it returns 0 as the count of assets - rather than the 6 that are in the simulator.

As a further comment on this - I’ve tried to compare this method of access with Apples Swift demonstration “PhPickerDemo” . The main differences I notice are the use of phPickerViewController and phPickerConfiguration - rather than the phAssetCollection and Fetch routines. Are these classes available for Xojo anywhere?

phPickerViewController and phPickerConfiguration are available starting in iOS14.
I have not seen these classes available for Xojo yet, but you would need a backup plan if your app is running on an older iOS version.

I am not sure why the code doesn’t work as intended.
Did you see messages about e.g. missing entitlements?

And I may ad more PH* objects for iOS 14 in the next months.
But it should all work with the older APIs, too.

1 Like

No, I don’t see any messages relating to the Simulator or Xojo. The app includes the same plist as your Photos demo for MacOS.