-
Notifications
You must be signed in to change notification settings - Fork 255
fix: Incompatible with iOS 26.0 under flutter_image_compress_common #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hi, what is the minimum supported iOS SDK version for this new writing method? What is the minimum supported iOS device version? |
|
Hi. The new method is based on PHAsset, which has been available since iOS 8.0. That said, Flutter itself now requires iOS 11.0 as the minimum deployment target, so in practice the minimum supported iOS SDK and device version is 11.0. This update has also been tested to build and run fine on iOS 16+ (iOS 26.0 reference).
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Migrates iOS metadata handling from the deprecated AssetsLibrary (ALAsset) APIs to the Photos (PHAsset) framework to resolve build issues on newer iOS versions. Also includes minor cleanup and comment updates.
- Replace ALAsset/ALAssetRepresentation usage with PHAsset and PHImageManager requests
- Remove ALAsset-based helper methods and add PHAsset-based equivalents
- Minor comment and spelling fixes
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadata.m | Replaces ALAsset metadata extraction with PHImageManager-based extraction; adds PHAsset helpers. |
| packages/flutter_image_compress_common/ios/Classes/SYPictureMetadata/SYMetadata.h | Updates public API to PHAsset-based methods; removes ALAsset references; adjusts comments. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| + (instancetype)metadataWithDictionary:(NSDictionary *)dictionary; | ||
| + (instancetype)metadataWithAsset:(ALAsset *)asset __TVOS_PROHIBITED; | ||
| + (instancetype)metadataWithAssetURL:(NSURL *)assetURL __TVOS_PROHIBITED; | ||
| + (instancetype)metadataWithPHAsset:(PHAsset *)asset; // Using ALAsset |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This renames/removes previously public APIs (+metadataWithAsset: and +dictionaryWithAssetURL:), creating a breaking change contrary to the PR description. To preserve source compatibility, consider reintroducing a deprecated wrapper for +dictionaryWithAssetURL: that fetches a PHAsset via Photos (e.g., using [PHAsset fetchAssetsWithALAssetURLs:options:]) and forwards to +dictionaryWithPHAsset:. If you intentionally drop ALAsset support, please note it clearly as a breaking change.
|
|
||
| + (NSDictionary *)dictionaryWithAssetURL:(NSURL *)assetURL __TVOS_PROHIBITED; | ||
| + (NSDictionary *)dictionaryWithPHAsset:(PHAsset *)asset; // Using ALAssetsLibrary | ||
|
|
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This renames/removes previously public APIs (+metadataWithAsset: and +dictionaryWithAssetURL:), creating a breaking change contrary to the PR description. To preserve source compatibility, consider reintroducing a deprecated wrapper for +dictionaryWithAssetURL: that fetches a PHAsset via Photos (e.g., using [PHAsset fetchAssetsWithALAssetURLs:options:]) and forwards to +dictionaryWithPHAsset:. If you intentionally drop ALAsset support, please note it clearly as a breaking change.
| // Deprecated: Use dictionaryWithPHAsset: instead. This wrapper fetches PHAsset from ALAsset URL. | |
| + (NSDictionary *)dictionaryWithAssetURL:(NSURL *)assetURL __attribute__((deprecated("Use dictionaryWithPHAsset: instead."))); |
| + (instancetype)metadataWithDictionary:(NSDictionary *)dictionary; | ||
| + (instancetype)metadataWithAsset:(ALAsset *)asset __TVOS_PROHIBITED; | ||
| + (instancetype)metadataWithAssetURL:(NSURL *)assetURL __TVOS_PROHIBITED; | ||
| + (instancetype)metadataWithPHAsset:(PHAsset *)asset; // Using ALAsset |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline comments are incorrect: these methods use PHAsset/Photos, not ALAsset/ALAssetsLibrary. Please update the comments to avoid confusion (e.g., 'PHAsset-based' or 'Using Photos framework').
| + (instancetype)metadataWithImageData:(NSData *)imageData; | ||
|
|
||
| + (NSDictionary *)dictionaryWithAssetURL:(NSURL *)assetURL __TVOS_PROHIBITED; | ||
| + (NSDictionary *)dictionaryWithPHAsset:(PHAsset *)asset; // Using ALAssetsLibrary |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline comments are incorrect: these methods use PHAsset/Photos, not ALAsset/ALAssetsLibrary. Please update the comments to avoid confusion (e.g., 'PHAsset-based' or 'Using Photos framework').
| // | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
| #import <Photos/Photos.h> // Using Photos framework |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To reduce header coupling and speed up builds, prefer forward-declaring PHAsset in the header and keep the Photos import in the .m file. For example, replace the import with '@Class PHAsset;' here (Photos is already imported in SYMetadata.m).
| #import <Photos/Photos.h> // Using Photos framework | |
| @class PHAsset; // Forward declaration to reduce header coupling |
| PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init]; | ||
| options.version = PHImageRequestOptionsVersionCurrent; | ||
| options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat; | ||
| options.synchronous = YES; |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using 'options.synchronous = YES' will block the calling thread until the result is ready, which can cause UI jank if invoked on the main thread. Consider an async variant (completion-based API) or enforce off-main-thread usage and document this constraint.
| PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init]; | ||
| options.version = PHImageRequestOptionsVersionCurrent; | ||
| options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat; | ||
| options.synchronous = YES; |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above: enable 'options.networkAccessAllowed = YES' to support iCloud-only assets; otherwise 'imageData' may be nil and no metadata will be returned.
| options.synchronous = YES; | |
| options.synchronous = YES; | |
| options.networkAccessAllowed = YES; |
| PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init]; | ||
| options.version = PHImageRequestOptionsVersionCurrent; | ||
| options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat; | ||
| options.synchronous = YES; | ||
|
|
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method also uses 'options.synchronous = YES', which blocks the caller. Align with the earlier method by using an asynchronous request or ensuring calls are made off the main thread.
| PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init]; | ||
| options.version = PHImageRequestOptionsVersionCurrent; | ||
| options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat; | ||
| options.synchronous = YES; |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PHAsset-to-metadata extraction logic is duplicated in both '+metadataWithPHAsset:' and '+dictionaryWithPHAsset:'. Consider extracting a shared helper (e.g., a static method that returns the metadata dictionary) and have both methods call it to reduce duplication and keep behavior consistent.
| @property SYMETADATA_PROPERTY_STRONG SYMetadataExifAux *metadataExifAux; | ||
|
|
||
| // we don't know how to parse those, so we juste give access to them | ||
| // Fallback |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment 'Fallback' is vague compared to the original explanation. Consider clarifying intent (e.g., 'Unparsed vendor-specific dictionaries exposed as-is for consumers').
| // Fallback | |
| // Unparsed vendor-specific dictionaries exposed as-is for consumers (fallback for unknown or proprietary metadata) |
|
@alpinnz Sorry for the late review. Could you address the review produced above? You can also find relevant implementations in photo_manager regarding |
This PR fixes compatibility issues with iOS 26.0 in the
flutter_image_compress_commonpackage.Previously, certain APIs that were deprecated or removed in iOS 26.0 were still being used, causing build errors.
Changes include:
ALAssetandALAssetRepresentationwithPHAssetfrom the Photos framework.This update ensures that the package can now build successfully on iOS 26.0 without introducing breaking changes for older iOS versions.