From 374d0f4a6a261c03b1ea10d553d60f8baf032d0f Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 10 Jun 2025 16:15:33 -0400 Subject: [PATCH 1/2] [google_maps_flutter] Fix iOS analysis for newer Xcode Fixes analysis failures that fail CI in newer versions of the toolchain. Currently these are surfaced in the Xcode UI, but not the command-line analysis run done in CI. This unblocks future CI updates. Fixes https://github.com/flutter/flutter/issues/170354 --- .../google_maps_flutter_ios/CHANGELOG.md | 3 +- .../ios/Classes/FGMImageUtils.h | 2 +- .../ios/Classes/FGMImageUtils.m | 10 +++---- .../ios/Classes/GoogleMapController.m | 28 +++++++++---------- .../google_maps_flutter_ios/pubspec.yaml | 2 +- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index faa4b3b62a94..532ebd289c60 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.15.3 +* Fixes new analysis warnings. * Updates minimum supported SDK version to Flutter 3.27/Dart 3.6. ## 2.15.2 diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h index 8aa1bcb67934..3c2b138a3bd4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN /// Creates a UIImage from Pigeon bitmap. -UIImage *FGMIconFromBitmap(FGMPlatformBitmap *platformBitmap, +UIImage * _Nullable FGMIconFromBitmap(FGMPlatformBitmap *platformBitmap, NSObject *registrar, CGFloat screenScale); /// Returns a BOOL indicating whether image is considered scalable with the given scale factor from /// size. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m index 3830ea28f604..9b5c1f8ec530 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m @@ -191,18 +191,18 @@ UIImage *scaledImageWithWidthHeight(UIImage *image, NSNumber *width, NSNumber *height, CGFloat screenScale) { - if (!width && !height) { + if ((width == nil) && (height == nil)) { return image; } - CGFloat targetWidth = width ? width.doubleValue : image.size.width; - CGFloat targetHeight = height ? height.doubleValue : image.size.height; + CGFloat targetWidth = width == nil ? image.size.width : width.doubleValue; + CGFloat targetHeight = height == nil ? image.size.height : height.doubleValue; - if (width && !height) { + if ((width != nil) && (height == nil)) { // Calculate height based on aspect ratio if only width is provided. double aspectRatio = image.size.height / image.size.width; targetHeight = round(targetWidth * aspectRatio); - } else if (!width && height) { + } else if ((width == nil) && (height != nil)) { // Calculate width based on aspect ratio if only height is provided. double aspectRatio = image.size.width / image.size.height; targetWidth = round(targetHeight * aspectRatio); diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m index 6844a67fb9b0..0bf1b58a80fb 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m @@ -436,19 +436,19 @@ - (void)interpretMapConfiguration:(FGMPlatformMapConfiguration *)config { : nil]; } NSNumber *compassEnabled = config.compassEnabled; - if (compassEnabled) { + if (compassEnabled != nil) { [self setCompassEnabled:compassEnabled.boolValue]; } NSNumber *indoorEnabled = config.indoorViewEnabled; - if (indoorEnabled) { + if (indoorEnabled != nil) { [self setIndoorEnabled:indoorEnabled.boolValue]; } NSNumber *trafficEnabled = config.trafficEnabled; - if (trafficEnabled) { + if (trafficEnabled != nil) { [self setTrafficEnabled:trafficEnabled.boolValue]; } NSNumber *buildingsEnabled = config.buildingsEnabled; - if (buildingsEnabled) { + if (buildingsEnabled != nil) { [self setBuildingsEnabled:buildingsEnabled.boolValue]; } FGMPlatformMapTypeBox *mapType = config.mapType; @@ -457,8 +457,8 @@ - (void)interpretMapConfiguration:(FGMPlatformMapConfiguration *)config { } FGMPlatformZoomRange *zoomData = config.minMaxZoomPreference; if (zoomData) { - float minZoom = zoomData.min ? zoomData.min.floatValue : kGMSMinZoomLevel; - float maxZoom = zoomData.max ? zoomData.max.floatValue : kGMSMaxZoomLevel; + float minZoom = zoomData.min != nil ? zoomData.min.floatValue : kGMSMinZoomLevel; + float maxZoom = zoomData.max != nil ? zoomData.max.floatValue : kGMSMaxZoomLevel; [self setMinZoom:minZoom maxZoom:maxZoom]; } FGMPlatformEdgeInsets *padding = config.padding; @@ -467,31 +467,31 @@ - (void)interpretMapConfiguration:(FGMPlatformMapConfiguration *)config { } NSNumber *rotateGesturesEnabled = config.rotateGesturesEnabled; - if (rotateGesturesEnabled) { + if (rotateGesturesEnabled != nil) { [self setRotateGesturesEnabled:rotateGesturesEnabled.boolValue]; } NSNumber *scrollGesturesEnabled = config.scrollGesturesEnabled; - if (scrollGesturesEnabled) { + if (scrollGesturesEnabled != nil) { [self setScrollGesturesEnabled:scrollGesturesEnabled.boolValue]; } NSNumber *tiltGesturesEnabled = config.tiltGesturesEnabled; - if (tiltGesturesEnabled) { + if (tiltGesturesEnabled != nil) { [self setTiltGesturesEnabled:tiltGesturesEnabled.boolValue]; } NSNumber *trackCameraPosition = config.trackCameraPosition; - if (trackCameraPosition) { + if (trackCameraPosition != nil) { [self setTrackCameraPosition:trackCameraPosition.boolValue]; } NSNumber *zoomGesturesEnabled = config.zoomGesturesEnabled; - if (zoomGesturesEnabled) { + if (zoomGesturesEnabled != nil) { [self setZoomGesturesEnabled:zoomGesturesEnabled.boolValue]; } NSNumber *myLocationEnabled = config.myLocationEnabled; - if (myLocationEnabled) { + if (myLocationEnabled != nil) { [self setMyLocationEnabled:myLocationEnabled.boolValue]; } NSNumber *myLocationButtonEnabled = config.myLocationButtonEnabled; - if (myLocationButtonEnabled) { + if (myLocationButtonEnabled != nil) { [self setMyLocationButtonEnabled:myLocationButtonEnabled.boolValue]; } NSString *style = config.style; @@ -665,7 +665,7 @@ - (void)animateCameraWithUpdate:(nonnull FGMPlatformCameraUpdate *)cameraUpdate details:nil]; return; } - FGMCATransactionWrapper *transaction = durationMilliseconds ? self.transactionWrapper : nil; + FGMCATransactionWrapper *transaction = durationMilliseconds != nil ? self.transactionWrapper : nil; [transaction begin]; [transaction setAnimationDuration:[durationMilliseconds doubleValue] / 1000]; [self.controller.mapView animateWithCameraUpdate:update]; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml index 08ef36c14020..f7397a4ddc3f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_ios description: iOS implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.15.2 +version: 2.15.3 environment: sdk: ^3.6.0 From da7671da944b88744c3ced6274b289b9b407bec2 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 11 Jun 2025 07:58:14 -0400 Subject: [PATCH 2/2] Autoformat --- .../google_maps_flutter_ios/ios/Classes/FGMImageUtils.h | 5 +++-- .../ios/Classes/GoogleMapController.m | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h index 3c2b138a3bd4..d88da5ff3d0c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h @@ -9,8 +9,9 @@ NS_ASSUME_NONNULL_BEGIN /// Creates a UIImage from Pigeon bitmap. -UIImage * _Nullable FGMIconFromBitmap(FGMPlatformBitmap *platformBitmap, - NSObject *registrar, CGFloat screenScale); +UIImage *_Nullable FGMIconFromBitmap(FGMPlatformBitmap *platformBitmap, + NSObject *registrar, + CGFloat screenScale); /// Returns a BOOL indicating whether image is considered scalable with the given scale factor from /// size. BOOL FGMIsScalableWithScaleFactorFromSize(CGSize originalSize, CGSize targetSize); diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m index 0bf1b58a80fb..5e10afdccf29 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m @@ -665,7 +665,8 @@ - (void)animateCameraWithUpdate:(nonnull FGMPlatformCameraUpdate *)cameraUpdate details:nil]; return; } - FGMCATransactionWrapper *transaction = durationMilliseconds != nil ? self.transactionWrapper : nil; + FGMCATransactionWrapper *transaction = + durationMilliseconds != nil ? self.transactionWrapper : nil; [transaction begin]; [transaction setAnimationDuration:[durationMilliseconds doubleValue] / 1000]; [self.controller.mapView animateWithCameraUpdate:update];