From 533be95b1fe66505bf042d2f4727e602e3e2accf Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 27 Feb 2023 13:03:57 -0800 Subject: [PATCH] [camera] Update minimum Flutter version to 3.3 and iOS 11 (#3296) [camera] Update minimum Flutter version to 3.3 and iOS 11 --- packages/camera/camera/CHANGELOG.md | 4 ++ packages/camera/camera/README.md | 11 +-- .../ios/Flutter/AppFrameworkInfo.plist | 2 +- packages/camera/camera/example/ios/Podfile | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 9 ++- .../camera/example/ios/Runner/Info.plist | 4 ++ packages/camera/camera/pubspec.yaml | 2 +- .../camera/camera_avfoundation/CHANGELOG.md | 4 ++ .../ios/Flutter/AppFrameworkInfo.plist | 2 +- .../camera_avfoundation/example/ios/Podfile | 3 +- .../ios/Runner.xcodeproj/project.pbxproj | 9 ++- .../example/ios/Runner/Info.plist | 4 ++ .../ios/Classes/CameraPlugin.m | 72 +++++++++---------- .../camera_avfoundation/ios/Classes/FLTCam.h | 2 +- .../camera_avfoundation/ios/Classes/FLTCam.m | 23 ++---- .../ios/Classes/FLTCam_Test.h | 2 +- .../ios/Classes/FLTSavePhotoDelegate.m | 21 +----- .../ios/camera_avfoundation.podspec | 2 +- .../camera/camera_avfoundation/pubspec.yaml | 6 +- 19 files changed, 82 insertions(+), 102 deletions(-) diff --git a/packages/camera/camera/CHANGELOG.md b/packages/camera/camera/CHANGELOG.md index fd592e11fbe..2ca8f00ab4e 100644 --- a/packages/camera/camera/CHANGELOG.md +++ b/packages/camera/camera/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.3+2 + +* Updates iOS minimum version in README. + ## 0.10.3+1 * Updates links for the merge of flutter/plugins into flutter/packages. diff --git a/packages/camera/camera/README.md b/packages/camera/camera/README.md index bfad30fbd57..87a25eae127 100644 --- a/packages/camera/camera/README.md +++ b/packages/camera/camera/README.md @@ -6,9 +6,9 @@ A Flutter plugin for iOS, Android and Web allowing access to the device cameras. -| | Android | iOS | Web | -|----------------|---------|----------|------------------------| -| **Support** | SDK 21+ | iOS 10+* | [See `camera_web `][1] | +| | Android | iOS | Web | +|----------------|---------|-----------|------------------------| +| **Support** | SDK 21+ | iOS 11.0+ | [See `camera_web `][1] | ## Features @@ -23,11 +23,6 @@ First, add `camera` as a [dependency in your pubspec.yaml file](https://flutter. ### iOS -\* The camera plugin compiles for any version of iOS, but its functionality -requires iOS 10 or higher. If compiling for iOS 9, make sure to programmatically -check the version of iOS running on the device before using any camera plugin features. -The [device_info_plus](https://pub.dev/packages/device_info_plus) plugin, for example, can be used to check the iOS version. - Add two rows to the `ios/Runner/Info.plist`: * one with the key `Privacy - Camera Usage Description` and a usage description. diff --git a/packages/camera/camera/example/ios/Flutter/AppFrameworkInfo.plist b/packages/camera/camera/example/ios/Flutter/AppFrameworkInfo.plist index 3a9c234f96d..9b41e7d8798 100644 --- a/packages/camera/camera/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/camera/camera/example/ios/Flutter/AppFrameworkInfo.plist @@ -25,6 +25,6 @@ arm64 MinimumOSVersion - 9.0 + 11.0 diff --git a/packages/camera/camera/example/ios/Podfile b/packages/camera/camera/example/ios/Podfile index f7d6a5e68c3..d207307f86d 100644 --- a/packages/camera/camera/example/ios/Podfile +++ b/packages/camera/camera/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj b/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj index 99433b084f2..59fa9076ed8 100644 --- a/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -212,10 +212,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -226,6 +228,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -343,7 +346,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -393,7 +396,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/packages/camera/camera/example/ios/Runner/Info.plist b/packages/camera/camera/example/ios/Runner/Info.plist index ff2e341a180..bacd9e54f1e 100644 --- a/packages/camera/camera/example/ios/Runner/Info.plist +++ b/packages/camera/camera/example/ios/Runner/Info.plist @@ -52,5 +52,9 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/packages/camera/camera/pubspec.yaml b/packages/camera/camera/pubspec.yaml index 775187b7325..74ef53c3878 100644 --- a/packages/camera/camera/pubspec.yaml +++ b/packages/camera/camera/pubspec.yaml @@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing Dart. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.10.3+1 +version: 0.10.3+2 environment: sdk: ">=2.14.0 <3.0.0" diff --git a/packages/camera/camera_avfoundation/CHANGELOG.md b/packages/camera/camera_avfoundation/CHANGELOG.md index f0fc9e80975..b230343cf1c 100644 --- a/packages/camera/camera_avfoundation/CHANGELOG.md +++ b/packages/camera/camera_avfoundation/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.12 + +* Updates minimum Flutter version to 3.3 and iOS 11. + ## 0.9.11+1 * Updates links for the merge of flutter/plugins into flutter/packages. diff --git a/packages/camera/camera_avfoundation/example/ios/Flutter/AppFrameworkInfo.plist b/packages/camera/camera_avfoundation/example/ios/Flutter/AppFrameworkInfo.plist index 3a9c234f96d..9b41e7d8798 100644 --- a/packages/camera/camera_avfoundation/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/camera/camera_avfoundation/example/ios/Flutter/AppFrameworkInfo.plist @@ -25,6 +25,6 @@ arm64 MinimumOSVersion - 9.0 + 11.0 diff --git a/packages/camera/camera_avfoundation/example/ios/Podfile b/packages/camera/camera_avfoundation/example/ios/Podfile index 5bc7b7e8571..8af57a7b8a6 100644 --- a/packages/camera/camera_avfoundation/example/ios/Podfile +++ b/packages/camera/camera_avfoundation/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' @@ -31,7 +31,6 @@ target 'Runner' do flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) target 'RunnerTests' do - platform :ios, '9.0' inherit! :search_paths # Pods for testing pod 'OCMock', '~> 3.8.1' diff --git a/packages/camera/camera_avfoundation/example/ios/Runner.xcodeproj/project.pbxproj b/packages/camera/camera_avfoundation/example/ios/Runner.xcodeproj/project.pbxproj index 03c80d79c57..d70d27fd8c2 100644 --- a/packages/camera/camera_avfoundation/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/camera/camera_avfoundation/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -336,10 +336,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -372,6 +374,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -574,7 +577,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -624,7 +627,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/packages/camera/camera_avfoundation/example/ios/Runner/Info.plist b/packages/camera/camera_avfoundation/example/ios/Runner/Info.plist index ff2e341a180..bacd9e54f1e 100644 --- a/packages/camera/camera_avfoundation/example/ios/Runner/Info.plist +++ b/packages/camera/camera_avfoundation/example/ios/Runner/Info.plist @@ -52,5 +52,9 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/packages/camera/camera_avfoundation/ios/Classes/CameraPlugin.m b/packages/camera/camera_avfoundation/ios/Classes/CameraPlugin.m index b85f68d1f95..535887622c5 100644 --- a/packages/camera/camera_avfoundation/ios/Classes/CameraPlugin.m +++ b/packages/camera/camera_avfoundation/ios/Classes/CameraPlugin.m @@ -104,43 +104,39 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FLTThreadSafeFlutterResult *)result { if ([@"availableCameras" isEqualToString:call.method]) { - if (@available(iOS 10.0, *)) { - NSMutableArray *discoveryDevices = - [@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera ] - mutableCopy]; - if (@available(iOS 13.0, *)) { - [discoveryDevices addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; - } - AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession - discoverySessionWithDeviceTypes:discoveryDevices - mediaType:AVMediaTypeVideo - position:AVCaptureDevicePositionUnspecified]; - NSArray *devices = discoverySession.devices; - NSMutableArray *> *reply = - [[NSMutableArray alloc] initWithCapacity:devices.count]; - for (AVCaptureDevice *device in devices) { - NSString *lensFacing; - switch ([device position]) { - case AVCaptureDevicePositionBack: - lensFacing = @"back"; - break; - case AVCaptureDevicePositionFront: - lensFacing = @"front"; - break; - case AVCaptureDevicePositionUnspecified: - lensFacing = @"external"; - break; - } - [reply addObject:@{ - @"name" : [device uniqueID], - @"lensFacing" : lensFacing, - @"sensorOrientation" : @90, - }]; + NSMutableArray *discoveryDevices = + [@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera ] + mutableCopy]; + if (@available(iOS 13.0, *)) { + [discoveryDevices addObject:AVCaptureDeviceTypeBuiltInUltraWideCamera]; + } + AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession + discoverySessionWithDeviceTypes:discoveryDevices + mediaType:AVMediaTypeVideo + position:AVCaptureDevicePositionUnspecified]; + NSArray *devices = discoverySession.devices; + NSMutableArray *> *reply = + [[NSMutableArray alloc] initWithCapacity:devices.count]; + for (AVCaptureDevice *device in devices) { + NSString *lensFacing; + switch ([device position]) { + case AVCaptureDevicePositionBack: + lensFacing = @"back"; + break; + case AVCaptureDevicePositionFront: + lensFacing = @"front"; + break; + case AVCaptureDevicePositionUnspecified: + lensFacing = @"external"; + break; } - [result sendSuccessWithData:reply]; - } else { - [result sendNotImplemented]; + [reply addObject:@{ + @"name" : [device uniqueID], + @"lensFacing" : lensFacing, + @"sensorOrientation" : @90, + }]; } + [result sendSuccessWithData:reply]; } else if ([@"create" isEqualToString:call.method]) { [self handleCreateMethodCall:call result:result]; } else if ([@"startImageStream" isEqualToString:call.method]) { @@ -188,11 +184,7 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call [_camera start]; [result sendSuccess]; } else if ([@"takePicture" isEqualToString:call.method]) { - if (@available(iOS 10.0, *)) { - [_camera captureToFile:result]; - } else { - [result sendNotImplemented]; - } + [_camera captureToFile:result]; } else if ([@"dispose" isEqualToString:call.method]) { [_registry unregisterTexture:cameraId]; [_camera close]; diff --git a/packages/camera/camera_avfoundation/ios/Classes/FLTCam.h b/packages/camera/camera_avfoundation/ios/Classes/FLTCam.h index 85b8e2ae06f..50a035494c7 100644 --- a/packages/camera/camera_avfoundation/ios/Classes/FLTCam.h +++ b/packages/camera/camera_avfoundation/ios/Classes/FLTCam.h @@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)start; - (void)stop; - (void)setDeviceOrientation:(UIDeviceOrientation)orientation; -- (void)captureToFile:(FLTThreadSafeFlutterResult *)result API_AVAILABLE(ios(10)); +- (void)captureToFile:(FLTThreadSafeFlutterResult *)result; - (void)close; - (void)startVideoRecordingWithResult:(FLTThreadSafeFlutterResult *)result; /** diff --git a/packages/camera/camera_avfoundation/ios/Classes/FLTCam.m b/packages/camera/camera_avfoundation/ios/Classes/FLTCam.m index a7d6cd24be3..2bfa3e5f1fa 100644 --- a/packages/camera/camera_avfoundation/ios/Classes/FLTCam.m +++ b/packages/camera/camera_avfoundation/ios/Classes/FLTCam.m @@ -167,11 +167,10 @@ - (instancetype)initWithCameraName:(NSString *)cameraName [_captureSession addOutputWithNoConnections:_captureVideoOutput]; [_captureSession addConnection:connection]; - if (@available(iOS 10.0, *)) { - _capturePhotoOutput = [AVCapturePhotoOutput new]; - [_capturePhotoOutput setHighResolutionCaptureEnabled:YES]; - [_captureSession addOutput:_capturePhotoOutput]; - } + _capturePhotoOutput = [AVCapturePhotoOutput new]; + [_capturePhotoOutput setHighResolutionCaptureEnabled:YES]; + [_captureSession addOutput:_capturePhotoOutput]; + _motionManager = [[CMMotionManager alloc] init]; [_motionManager startAccelerometerUpdates]; @@ -229,7 +228,7 @@ - (void)updateOrientation:(UIDeviceOrientation)orientation } } -- (void)captureToFile:(FLTThreadSafeFlutterResult *)result API_AVAILABLE(ios(10)) { +- (void)captureToFile:(FLTThreadSafeFlutterResult *)result { AVCapturePhotoSettings *settings = [AVCapturePhotoSettings photoSettings]; if (_resolutionPreset == FLTResolutionPresetMax) { [settings setHighResolutionPhotoEnabled:YES]; @@ -1002,19 +1001,11 @@ - (void)setZoomLevel:(CGFloat)zoom Result:(FLTThreadSafeFlutterResult *)result { } - (CGFloat)getMinAvailableZoomFactor { - if (@available(iOS 11.0, *)) { - return _captureDevice.minAvailableVideoZoomFactor; - } else { - return 1.0; - } + return _captureDevice.minAvailableVideoZoomFactor; } - (CGFloat)getMaxAvailableZoomFactor { - if (@available(iOS 11.0, *)) { - return _captureDevice.maxAvailableVideoZoomFactor; - } else { - return _captureDevice.activeFormat.videoMaxZoomFactor; - } + return _captureDevice.maxAvailableVideoZoomFactor; } - (BOOL)setupWriterForPath:(NSString *)path { diff --git a/packages/camera/camera_avfoundation/ios/Classes/FLTCam_Test.h b/packages/camera/camera_avfoundation/ios/Classes/FLTCam_Test.h index 19e284227f4..49a2752f828 100644 --- a/packages/camera/camera_avfoundation/ios/Classes/FLTCam_Test.h +++ b/packages/camera/camera_avfoundation/ios/Classes/FLTCam_Test.h @@ -25,7 +25,7 @@ @property(readonly, nonatomic) AVCaptureVideoDataOutput *captureVideoOutput; /// The output for photo capturing. Exposed setter for unit tests. -@property(strong, nonatomic) AVCapturePhotoOutput *capturePhotoOutput API_AVAILABLE(ios(10)); +@property(strong, nonatomic) AVCapturePhotoOutput *capturePhotoOutput; /// True when images from the camera are being streamed. @property(assign, nonatomic) BOOL isStreamingImages; diff --git a/packages/camera/camera_avfoundation/ios/Classes/FLTSavePhotoDelegate.m b/packages/camera/camera_avfoundation/ios/Classes/FLTSavePhotoDelegate.m index 617890c4405..310ffdb04eb 100644 --- a/packages/camera/camera_avfoundation/ios/Classes/FLTSavePhotoDelegate.m +++ b/packages/camera/camera_avfoundation/ios/Classes/FLTSavePhotoDelegate.m @@ -46,28 +46,9 @@ - (void)handlePhotoCaptureResultWithError:(NSError *)error }); } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -- (void)captureOutput:(AVCapturePhotoOutput *)output - didFinishProcessingPhotoSampleBuffer:(CMSampleBufferRef)photoSampleBuffer - previewPhotoSampleBuffer:(CMSampleBufferRef)previewPhotoSampleBuffer - resolvedSettings:(AVCaptureResolvedPhotoSettings *)resolvedSettings - bracketSettings:(AVCaptureBracketedStillImageSettings *)bracketSettings - error:(NSError *)error API_AVAILABLE(ios(10)) { - [self handlePhotoCaptureResultWithError:error - photoDataProvider:^NSData * { - return [AVCapturePhotoOutput - JPEGPhotoDataRepresentationForJPEGSampleBuffer:photoSampleBuffer - previewPhotoSampleBuffer: - previewPhotoSampleBuffer]; - }]; -} -#pragma clang diagnostic pop - - (void)captureOutput:(AVCapturePhotoOutput *)output didFinishProcessingPhoto:(AVCapturePhoto *)photo - error:(NSError *)error API_AVAILABLE(ios(11.0)) { + error:(NSError *)error { [self handlePhotoCaptureResultWithError:error photoDataProvider:^NSData * { return [photo fileDataRepresentation]; diff --git a/packages/camera/camera_avfoundation/ios/camera_avfoundation.podspec b/packages/camera/camera_avfoundation/ios/camera_avfoundation.podspec index 0cbdc9a450c..3fe435bdc28 100644 --- a/packages/camera/camera_avfoundation/ios/camera_avfoundation.podspec +++ b/packages/camera/camera_avfoundation/ios/camera_avfoundation.podspec @@ -18,6 +18,6 @@ A Flutter plugin to use the camera from your Flutter app. s.module_map = 'Classes/CameraPlugin.modulemap' s.dependency 'Flutter' - s.platform = :ios, '9.0' + s.platform = :ios, '11.0' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } end diff --git a/packages/camera/camera_avfoundation/pubspec.yaml b/packages/camera/camera_avfoundation/pubspec.yaml index d320fdc72b6..c7483d9e46b 100644 --- a/packages/camera/camera_avfoundation/pubspec.yaml +++ b/packages/camera/camera_avfoundation/pubspec.yaml @@ -2,11 +2,11 @@ name: camera_avfoundation description: iOS implementation of the camera plugin. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_avfoundation issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.9.11+1 +version: 0.9.12 environment: - sdk: ">=2.14.0 <3.0.0" - flutter: ">=3.0.0" + sdk: '>=2.18.0 <3.0.0' + flutter: ">=3.3.0" flutter: plugin: