Skip to content

Latest commit

 

History

History
305 lines (294 loc) · 44.7 KB

Photos.md

File metadata and controls

305 lines (294 loc) · 44.7 KB

Photos

Symbols: 60.0% of Apple's iOS API (399 of 665, exact) · Rows: 11: 7 ✅ 1 🟡 3 ❌ · iOS: 8.0+

Area: Imaging, photos & ML · Apple: Photos · Issues: area:ml

How isim implements it

  • Adapted: a simulated photo library in $ISIM_DATA/Media (six generated pictures, plus the photos, videos and albums apps save), with the permission alerts.
  • Objective-C / C interface: #import <Photos/Photos.h> and -framework Photos (headers in isim/sdk-src/Frameworks/Photos) reach the Swift overlay's classes under their Objective-C names, with Apple's selectors (isim/swift/overlays/Photos/ObjC.swift for what uses Swift-only types). PHFetchResult, PHFetchResultChangeDetails and PHObjectChangeDetails are Swift generics, so Objective-C has classes of its own (isim/frameworks/Photos/Photos.m) over the objects a fetch returned.

API

API / feature Status iOS Notes
Photos (PHPhotoLibrary, PHAsset, saving images) 🟡 ≤17 device library in $ISIM_DATA/Media seeded with 6 generated sample pictures (stand-ins for the Simulator's); permission alert (full / limited with selection / add-only) remembered per app; fetch with sort/limit and predicates (mediaType, creationDate, favorite, pixelWidth, …), smart albums (Recents, Favorites, Videos), PHImageManager scaling, PHAssetChangeRequest create/favorite/delete (with confirmation), change observers; Live Photos and edits (rows below)
Photos' Objective-C interface: Photos.h and the class headers (PHPhotoLibrary.h, PHAsset.h, PHCollection.h, PHFetchResult.h, PHFetchOptions.h, PHChange.h, PHImageManager.h, PHAssetChangeRequest.h, PHAssetCollectionChangeRequest.h, PHAssetResource.h, PHAssetResourceManager.h, PHError.h, PhotosTypes.h), the enums, PHImage…Key, PHImageManagerMaximumSize, PHPhotosErrorDomain, PHLocalIdentifierNotFound, PHPhotoLibraryChangeObserver ✅ ≤17 adapted: the Swift classes under their Objective-C names (OBJC_NAMES keeps their old class symbols); Objective-C's PHFetchResult holds the objects of the fetch (indexing, NSFastEnumeration, block enumeration, countOfAssetsWithMediaType:) and runs it again for -[PHChange changeDetailsForFetchResult:], whose inserted, removed and changed indexes compare the two (no moves); change requests take an NSArray or a PHFetchResult; the Live Photo and editing classes (PHLivePhoto.h, PHContentEditing.h, PHAdjustmentData.h, PHContentEditingInput.h, PHContentEditingOutput.h, PHLivePhotoRequestOptions, requestLivePhotoForAsset:…, requestContentEditingInputWithOptions:completionHandler:, contentEditingOutput, PHAssetPlaybackStyle, the PHContentEditingInput…Key and PHLivePhotoInfo…Key constants); no PHCollectionList or persistent changes; the classes are not subclassable from Objective-C. Tested (tests/photos-objc: fetches, image and data requests, resources, saving into a new album, favourites, a change observer)
Videos: PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL:), PHAssetCreationRequest .video resources, PHImageManager.requestAVAsset(forVideo:options:resultHandler:), requestPlayerItem(forVideo:options:resultHandler:), requestExportSession(forVideo:options:exportPreset:resultHandler:), PHVideoRequestOptions ✅ ≤17 adapted: movies are copied into the library with a poster frame (as UISaveVideoAtPathToSavedPhotosAlbum does), with their duration and size; requests give an AVURLAsset / AVPlayerItem / AVAssetExportSession over the library file on a background queue; isim keeps one version of each video, so version, deliveryMode and network access change nothing; no AVAudioMix; tested (HelloPhotos, test_photos_videos_albums)
Albums: PHAssetCollectionChangeRequest (creationRequestForAssetCollection(withTitle:), init(for:), init(for:assets:), title, addAssets, insertAssets(_:at:), removeAssets, removeAssets(at:), replaceAssets(at:withAssets:), moveAssets(at:to:), deleteAssetCollections), PHAssetCollection.fetchAssetCollections(with: .album …), fetchAssetCollectionsContaining(_:with:options:), PHCollection.fetchTopLevelUserCollections(with:), canPerform(_:) ✅ ≤17 adapted: user albums kept in the library index, in their own order; fetch predicates and sorting on title / localizedTitle; the asset arguments take an NSArray, a PHFetchResult or placeholders (typed Any, where Apple's are NSFastEnumeration); no folders (PHCollectionList) or shared albums; tested (HelloPhotos, test_photos_videos_albums)
Resources: PHAssetResource.assetResources(for:), PHAssetResourceManager (requestData(for:options:dataReceivedHandler:completionHandler:), writeData(for:toFile:options:), cancelDataRequest), PHAssetResourceRequestOptions ✅ ≤17 adapted: each asset has one resource, its photo or video file (.photo / .video, with its type identifier); data comes in chunks on a background queue; writeData fails when the file exists, as on iOS; tested (HelloPhotos, test_photos_videos_albums)
Live Photos: PHLivePhoto (size, request(withResourceFileURLs:placeholderImage:targetSize:contentMode:resultHandler:), cancelRequest(withRequestID:), NSSecureCoding, NSItemProviderReading in PhotosUI), PHLivePhotoRequestOptions, PHImageManager.requestLivePhoto(for:targetSize:contentMode:options:resultHandler:), PHAssetCreationRequest .photo + .pairedVideo, PHAsset.playbackStyle, PHAssetMediaSubtype.photoLive, the paired resource types ✅ ≤17 adapted: a Live Photo is a library still with its movie kept beside it (IMG_0007.JPG, IMG_0007.MOV), reported as photoLive / .livePhoto with .photo and .pairedVideo resources; requests answer on the main queue (a placeholder first, degraded, when one is given); no Live Photo editing (PHLivePhotoEditingContext); tested (HelloPhotos, test_photos_live_edits)
Editing: PHContentEditingInput (mediaType, mediaSubtypes, creationDate, location, uniformTypeIdentifier, contentType, playbackStyle, adjustmentData, displaySizeImage, fullSizeImageURL, fullSizeImageOrientation, audiovisualAsset, livePhoto), PHContentEditingOutput (init(contentEditingInput:), init(placeholderForCreatedAsset:), adjustmentData, renderedContentURL, renderedContentURL(for:), defaultRenderedContentType, supportedRenderedContentTypes), PHAdjustmentData, PHContentEditingInputRequestOptions, PHAsset.requestContentEditingInput(with:completionHandler:), cancelContentEditingInputRequest, hasAdjustments, PHAssetChangeRequest.contentEditingOutput, revertAssetContentToOriginal() ✅ ≤17 adapted: an edit keeps the original and stores the rendered file (IMG_0007_E.JPG) and the adjustment data in the library; the current version shows the edit, .original / .unadjusted requests the original; the input is the original when canHandleAdjustmentData accepts the adjustments (with them), else the edit; edited assets list .fullSizePhoto and .adjustmentData resources; reverting removes the edit; tested (HelloPhotos, test_photos_live_edits)
UIImageWriteToSavedPhotosAlbum ✅ ≤17 add-only permission alert, completion selector called with nil/error
Types not yet in isim (iOS 17 and earlier) ❌ ≤17 not implemented, found by the 2026-10 sweep: PHCollectionList, PHLivePhoto, PHLivePhotoRequestOptions (3 types; with their members under "Not yet in isim")
Types not yet in isim (iOS 26) ❌ 26.1 not implemented, found by the 2026-10 sweep: PHAssetResourceUploadJob, PHAssetResourceUploadJobChangeRequest, PHBackgroundResourceUploadExtension (3 types; with their members under "Not yet in isim")
Types not yet in isim (iOS 27) ❌ 27.0 not implemented, found by the 2026-10 sweep: PHAssetExtendedMetadata, PHAssetResourceUploadJobOptions, PHBackgroundResourceUploadJobExtension, PHPhotoLibraryPersistentChangesObserver, PHReferenceImageInfo (5 types; with their members under "Not yet in isim")

Not yet in isim

266 symbols Apple documents for iOS that isim does not have (exact; Apple snapshot 2026-10-14). Each links to Apple's documentation.

List