Skip to content

Commit

Permalink
[camera] Update minimum Flutter version to 3.3 and iOS 11 (flutter#3296)
Browse files Browse the repository at this point in the history
[camera] Update minimum Flutter version to 3.3 and iOS 11
  • Loading branch information
jmagman committed Feb 27, 2023
1 parent 7ebf1d4 commit 533be95
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 102 deletions.
4 changes: 4 additions & 0 deletions 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.
Expand Down
11 changes: 3 additions & 8 deletions packages/camera/camera/README.md
Expand Up @@ -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

Expand All @@ -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.
Expand Down
Expand Up @@ -25,6 +25,6 @@
<string>arm64</string>
</array>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion 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'
Expand Down
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -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 = (
Expand All @@ -226,6 +228,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera/example/ios/Runner/Info.plist
Expand Up @@ -52,5 +52,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions 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.
Expand Down
Expand Up @@ -25,6 +25,6 @@
<string>arm64</string>
</array>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
3 changes: 1 addition & 2 deletions 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'
Expand Down Expand Up @@ -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'
Expand Down
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -372,6 +374,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down
Expand Up @@ -52,5 +52,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
72 changes: 32 additions & 40 deletions packages/camera/camera_avfoundation/ios/Classes/CameraPlugin.m
Expand Up @@ -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<AVCaptureDevice *> *devices = discoverySession.devices;
NSMutableArray<NSDictionary<NSString *, NSObject *> *> *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<AVCaptureDevice *> *devices = discoverySession.devices;
NSMutableArray<NSDictionary<NSString *, NSObject *> *> *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]) {
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_avfoundation/ios/Classes/FLTCam.h
Expand Up @@ -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;
/**
Expand Down
23 changes: 7 additions & 16 deletions packages/camera/camera_avfoundation/ios/Classes/FLTCam.m
Expand Up @@ -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];

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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 {
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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];
Expand Down
Expand Up @@ -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

0 comments on commit 533be95

Please sign in to comment.