From 1f3c635d19db3841a4af5860d9d2897eb95817b2 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Thu, 14 Jan 2021 23:59:00 +0100 Subject: [PATCH 01/19] Fix observing frame change only once --- .../google_maps_flutter/ios/Classes/GoogleMapController.m | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m index df4e8761e6b2..2af3cdf5f1d3 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m @@ -119,12 +119,13 @@ - (instancetype)initWithFrame:(CGRect)frame if ([tileOverlaysToAdd isKindOfClass:[NSArray class]]) { [_tileOverlaysController addTileOverlays:tileOverlaysToAdd]; } + + [_mapView addObserver:self forKeyPath:@"frame" options:0 context:nil]; } return self; } - (UIView *)view { - [_mapView addObserver:self forKeyPath:@"frame" options:0 context:nil]; return _mapView; } @@ -132,11 +133,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if (_cameraDidInitialSetup) { - // We only observe the frame for initial setup. - [_mapView removeObserver:self forKeyPath:@"frame"]; - return; - } if (object == _mapView && [keyPath isEqualToString:@"frame"]) { CGRect bounds = _mapView.bounds; if (CGRectEqualToRect(bounds, CGRectZero)) { From 2ff340f7f8c9a4955d744997e4fcc5122c9f9eb3 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Fri, 15 Jan 2021 00:21:44 +0100 Subject: [PATCH 02/19] Update pubspec and CHANGELOG --- packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index 565bf8412c61..4c767e0241fd 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -4,6 +4,10 @@ * Updates Android compileSdkVersion to 31. * Internal code cleanup for stricter analysis options. +## 2.1.2 + +* Fix iOS crash on `EXC_BAD_ACCESS KERN_PROTECTION_FAILURE` if the map frame changes long after creation. + ## 2.1.1 * Suppresses unchecked cast warning. From 6a2597822a3af511db2d9000f3e1ffa811cfc20c Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Fri, 15 Jan 2021 10:24:02 +0100 Subject: [PATCH 03/19] Remove hacky flags --- .../google_maps_flutter/ios/Classes/GoogleMapController.m | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m index 2af3cdf5f1d3..60a78c4f407f 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m @@ -51,7 +51,6 @@ @implementation FLTGoogleMapController { FlutterMethodChannel *_channel; BOOL _trackCameraPosition; NSObject *_registrar; - BOOL _cameraDidInitialSetup; FLTMarkersController *_markersController; FLTPolygonsController *_polygonsController; FLTPolylinesController *_polylinesController; @@ -83,7 +82,6 @@ - (instancetype)initWithFrame:(CGRect)frame }]; _mapView.delegate = weakSelf; _registrar = registrar; - _cameraDidInitialSetup = NO; _markersController = [[FLTMarkersController alloc] init:_channel mapView:_mapView registrar:registrar]; @@ -142,7 +140,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath // zero. return; } - _cameraDidInitialSetup = YES; [_mapView removeObserver:self forKeyPath:@"frame"]; [_mapView moveCamera:[GMSCameraUpdate setCamera:_mapView.camera]]; } else { From 94456f999391885c2d0cbfe0afdb39ef2fd6c131 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Mon, 14 Feb 2022 18:57:31 +0100 Subject: [PATCH 04/19] Add tests --- .../ios/Runner.xcodeproj/project.pbxproj | 6 ++ .../example/ios/RunnerTests/FlutterMock.h | 23 ++++++ .../example/ios/RunnerTests/FlutterMock.m | 74 +++++++++++++++++++ .../example/ios/RunnerTests/GoogleMapsTests.m | 23 ++++++ 4 files changed, 126 insertions(+) create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj index fbb006aeded0..c92ec4ecdcc5 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + 98FDF41F27BABE770021E74D /* FlutterMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 98FDF41E27BABE770021E74D /* FlutterMock.m */; }; F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */; }; F7151F21265D7EE50028CB91 /* GoogleMapsUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F20265D7EE50028CB91 /* GoogleMapsUITests.m */; }; FC8F35FC8CD533B128950487 /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F267F68029D1A4E2E4C572A7 /* libPods-RunnerTests.a */; }; @@ -67,6 +68,8 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 98FDF41D27BABE770021E74D /* FlutterMock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FlutterMock.h; sourceTree = ""; }; + 98FDF41E27BABE770021E74D /* FlutterMock.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlutterMock.m; sourceTree = ""; }; B7AFC65E3DD5AC60D834D83D /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; E52C6A6210A56F027C582EF9 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; EA0E91726245EDC22B97E8B9 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; @@ -187,6 +190,8 @@ F7151F11265D7ED70028CB91 /* RunnerTests */ = { isa = PBXGroup; children = ( + 98FDF41D27BABE770021E74D /* FlutterMock.h */, + 98FDF41E27BABE770021E74D /* FlutterMock.m */, F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */, F7151F14265D7ED70028CB91 /* Info.plist */, ); @@ -440,6 +445,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 98FDF41F27BABE770021E74D /* FlutterMock.m in Sources */, F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h new file mode 100644 index 000000000000..44d2b4311f3b --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h @@ -0,0 +1,23 @@ +// +// FlutterMock.h +// RunnerTests +// +// Created by Guy Kogus on 14/2/22. +// Copyright © 2022 The Flutter Authors. All rights reserved. +// + +@import Foundation; +@import Flutter; + +NS_ASSUME_NONNULL_BEGIN + +@interface MockRegistrar : NSObject +@end + +@interface MockBinaryMessenger : NSObject +@end + +@interface MockTextureRegistry : NSObject +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m new file mode 100644 index 000000000000..7f009e1c1efe --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m @@ -0,0 +1,74 @@ +// +// FlutterMock.m +// RunnerTests +// +// Created by Guy Kogus on 14/2/22. +// Copyright © 2022 The Flutter Authors. All rights reserved. +// + +#import "FlutterMock.h" + +@implementation MockRegistrar + +- (void)addApplicationDelegate:(nonnull NSObject *)delegate {} + +- (void)addMethodCallDelegate:(nonnull NSObject *)delegate channel:(nonnull FlutterMethodChannel *)channel { +} + +- (nonnull NSString *)lookupKeyForAsset:(nonnull NSString *)asset { + return @""; +} + +- (nonnull NSString *)lookupKeyForAsset:(nonnull NSString *)asset fromPackage:(nonnull NSString *)package { + return @""; +} + +- (nonnull NSObject *)messenger { + return [[MockBinaryMessenger alloc] init]; +} + +- (void)publish:(nonnull NSObject *)value { +} + +- (void)registerViewFactory:(nonnull NSObject *)factory withId:(nonnull NSString *)factoryId { +} + +- (void)registerViewFactory:(nonnull NSObject *)factory withId:(nonnull NSString *)factoryId gestureRecognizersBlockingPolicy:(FlutterPlatformViewGestureRecognizersBlockingPolicy)gestureRecognizersBlockingPolicy { +} + +- (nonnull NSObject *)textures { + return [[MockTextureRegistry alloc] init]; +} + +@end + +@implementation MockBinaryMessenger + +- (void)cleanUpConnection:(FlutterBinaryMessengerConnection)connection { +} + +- (void)sendOnChannel:(nonnull NSString *)channel message:(NSData * _Nullable)message { +} + +- (void)sendOnChannel:(nonnull NSString *)channel message:(NSData * _Nullable)message binaryReply:(FlutterBinaryReply _Nullable)callback { +} + +- (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(nonnull NSString *)channel binaryMessageHandler:(FlutterBinaryMessageHandler _Nullable)handler { + return 0; +} + +@end + +@implementation MockTextureRegistry + +- (int64_t)registerTexture:(nonnull NSObject *)texture { + return 0; +} + +- (void)textureFrameAvailable:(int64_t)textureId { +} + +- (void)unregisterTexture:(int64_t)textureId { +} + +@end diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m index a833c7441243..2dee619d23d9 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m @@ -5,6 +5,8 @@ @import google_maps_flutter; @import XCTest; +#import "FlutterMock.h" + @interface GoogleMapsTests : XCTestCase @end @@ -15,4 +17,25 @@ - (void)testPlugin { XCTAssertNotNil(plugin); } +- (void)testObserveCamera { + XCTestExpectation *viewExpectation = [self expectationWithDescription:@"View loaded"]; + + dispatch_async(dispatch_queue_create("", 0), ^{ + [self waitForExpectations:@[viewExpectation] timeout:1]; + }); + + MockRegistrar *object = [[MockRegistrar alloc] init]; + FLTGoogleMapController *controller = [[FLTGoogleMapController alloc] initWithFrame:CGRectMake(0, 0, 100, 100) + viewIdentifier:0 + arguments:@{} + registrar:object]; + + for (NSInteger i = 0; i < 10000; ++i) { + [controller view]; + } + [[controller view] setValue:[NSValue valueWithCGRect:CGRectMake(0, 0, 0, 0)] forKey:@"frame"]; + + [viewExpectation fulfill]; +} + @end From 416cf254a0bb971f29cff4e4b0fbaa94f725e1c0 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Mon, 14 Feb 2022 18:58:51 +0100 Subject: [PATCH 05/19] Update CHANGELOG --- packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index 4c767e0241fd..b41ad6d1a2be 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -1,4 +1,4 @@ -## 2.1.2 +## NEXT * Removes dependencies from `pubspec.yaml` that are only needed in `example/pubspec.yaml` * Updates Android compileSdkVersion to 31. From 9bca4e0d6623c3664403b10fcee5b1b890d6c7b4 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Mon, 14 Feb 2022 19:08:00 +0100 Subject: [PATCH 06/19] Fix formatting --- .../example/ios/RunnerTests/FlutterMock.h | 6 ++--- .../example/ios/RunnerTests/FlutterMock.m | 27 +++++++++++++------ .../example/ios/RunnerTests/GoogleMapsTests.m | 11 ++++---- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h index 44d2b4311f3b..d68971de9a0d 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h @@ -11,13 +11,13 @@ NS_ASSUME_NONNULL_BEGIN -@interface MockRegistrar : NSObject +@interface MockRegistrar : NSObject @end -@interface MockBinaryMessenger : NSObject +@interface MockBinaryMessenger : NSObject @end -@interface MockTextureRegistry : NSObject +@interface MockTextureRegistry : NSObject @end NS_ASSUME_NONNULL_END diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m index 7f009e1c1efe..dae12d33d966 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m @@ -10,16 +10,19 @@ @implementation MockRegistrar -- (void)addApplicationDelegate:(nonnull NSObject *)delegate {} +- (void)addApplicationDelegate:(nonnull NSObject *)delegate { +} -- (void)addMethodCallDelegate:(nonnull NSObject *)delegate channel:(nonnull FlutterMethodChannel *)channel { +- (void)addMethodCallDelegate:(nonnull NSObject *)delegate + channel:(nonnull FlutterMethodChannel *)channel { } - (nonnull NSString *)lookupKeyForAsset:(nonnull NSString *)asset { return @""; } -- (nonnull NSString *)lookupKeyForAsset:(nonnull NSString *)asset fromPackage:(nonnull NSString *)package { +- (nonnull NSString *)lookupKeyForAsset:(nonnull NSString *)asset + fromPackage:(nonnull NSString *)package { return @""; } @@ -30,10 +33,14 @@ - (nonnull NSString *)lookupKeyForAsset:(nonnull NSString *)asset fromPackage:(n - (void)publish:(nonnull NSObject *)value { } -- (void)registerViewFactory:(nonnull NSObject *)factory withId:(nonnull NSString *)factoryId { +- (void)registerViewFactory:(nonnull NSObject *)factory + withId:(nonnull NSString *)factoryId { } -- (void)registerViewFactory:(nonnull NSObject *)factory withId:(nonnull NSString *)factoryId gestureRecognizersBlockingPolicy:(FlutterPlatformViewGestureRecognizersBlockingPolicy)gestureRecognizersBlockingPolicy { +- (void)registerViewFactory:(nonnull NSObject *)factory + withId:(nonnull NSString *)factoryId + gestureRecognizersBlockingPolicy: + (FlutterPlatformViewGestureRecognizersBlockingPolicy)gestureRecognizersBlockingPolicy { } - (nonnull NSObject *)textures { @@ -47,13 +54,17 @@ @implementation MockBinaryMessenger - (void)cleanUpConnection:(FlutterBinaryMessengerConnection)connection { } -- (void)sendOnChannel:(nonnull NSString *)channel message:(NSData * _Nullable)message { +- (void)sendOnChannel:(nonnull NSString *)channel message:(NSData *_Nullable)message { } -- (void)sendOnChannel:(nonnull NSString *)channel message:(NSData * _Nullable)message binaryReply:(FlutterBinaryReply _Nullable)callback { +- (void)sendOnChannel:(nonnull NSString *)channel + message:(NSData *_Nullable)message + binaryReply:(FlutterBinaryReply _Nullable)callback { } -- (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(nonnull NSString *)channel binaryMessageHandler:(FlutterBinaryMessageHandler _Nullable)handler { +- (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(nonnull NSString *)channel + binaryMessageHandler: + (FlutterBinaryMessageHandler _Nullable)handler { return 0; } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m index 2dee619d23d9..a7e1d9577773 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m @@ -21,14 +21,15 @@ - (void)testObserveCamera { XCTestExpectation *viewExpectation = [self expectationWithDescription:@"View loaded"]; dispatch_async(dispatch_queue_create("", 0), ^{ - [self waitForExpectations:@[viewExpectation] timeout:1]; + [self waitForExpectations:@[ viewExpectation ] timeout:1]; }); MockRegistrar *object = [[MockRegistrar alloc] init]; - FLTGoogleMapController *controller = [[FLTGoogleMapController alloc] initWithFrame:CGRectMake(0, 0, 100, 100) - viewIdentifier:0 - arguments:@{} - registrar:object]; + FLTGoogleMapController *controller = + [[FLTGoogleMapController alloc] initWithFrame:CGRectMake(0, 0, 100, 100) + viewIdentifier:0 + arguments:@{} + registrar:object]; for (NSInteger i = 0; i < 10000; ++i) { [controller view]; From 9f483b1b153aaf82709aa7aa72b0166275c42ee5 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Mon, 14 Feb 2022 19:29:37 +0100 Subject: [PATCH 07/19] Add missing licence --- .../example/ios/RunnerTests/FlutterMock.h | 10 +++------- .../example/ios/RunnerTests/FlutterMock.m | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h index d68971de9a0d..f2e6c5a95c01 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h @@ -1,10 +1,6 @@ -// -// FlutterMock.h -// RunnerTests -// -// Created by Guy Kogus on 14/2/22. -// Copyright © 2022 The Flutter Authors. All rights reserved. -// +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. @import Foundation; @import Flutter; diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m index dae12d33d966..f55038a03024 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m @@ -1,10 +1,6 @@ -// -// FlutterMock.m -// RunnerTests -// -// Created by Guy Kogus on 14/2/22. -// Copyright © 2022 The Flutter Authors. All rights reserved. -// +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #import "FlutterMock.h" From 6ec103d3d37abd496376dd3539bfef06edbd9050 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Mon, 14 Feb 2022 20:36:09 +0100 Subject: [PATCH 08/19] Create mock map view to test counting the frame observers --- .../google_maps_flutter/CHANGELOG.md | 2 +- .../google_maps_flutter/example/ios/Podfile | 2 + .../ios/Runner.xcodeproj/project.pbxproj | 14 ++-- .../example/ios/RunnerTests/FlutterMock.h | 19 ----- .../example/ios/RunnerTests/FlutterMock.m | 81 ------------------- .../RunnerTests/GoogleMapController-Test.h | 19 +++++ .../example/ios/RunnerTests/GoogleMapsTests.m | 36 ++++----- .../example/ios/RunnerTests/MockGMSMapView.h | 15 ++++ .../example/ios/RunnerTests/MockGMSMapView.m | 28 +++++++ .../ios/Classes/GoogleMapController.m | 12 ++- 10 files changed, 101 insertions(+), 127 deletions(-) delete mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h delete mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapController-Test.h create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index b41ad6d1a2be..f95c09f67f60 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -6,7 +6,7 @@ ## 2.1.2 -* Fix iOS crash on `EXC_BAD_ACCESS KERN_PROTECTION_FAILURE` if the map frame changes long after creation. +* Fixes iOS crash on `EXC_BAD_ACCESS KERN_PROTECTION_FAILURE` if the map frame changes long after creation. ## 2.1.1 diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Podfile b/packages/google_maps_flutter/google_maps_flutter/example/ios/Podfile index 9686afaf3c99..e767825011cf 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/Podfile +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Podfile @@ -31,6 +31,8 @@ target 'Runner' do flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) target 'RunnerTests' do inherit! :search_paths + + pod 'OCMock' end end diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj index c92ec4ecdcc5..7a23bf96fb5f 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -15,7 +15,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - 98FDF41F27BABE770021E74D /* FlutterMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 98FDF41E27BABE770021E74D /* FlutterMock.m */; }; + 982F2A6C27BADE17003C81F4 /* MockGMSMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 982F2A6B27BADE17003C81F4 /* MockGMSMapView.m */; }; F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */; }; F7151F21265D7EE50028CB91 /* GoogleMapsUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F20265D7EE50028CB91 /* GoogleMapsUITests.m */; }; FC8F35FC8CD533B128950487 /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F267F68029D1A4E2E4C572A7 /* libPods-RunnerTests.a */; }; @@ -68,8 +68,9 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 98FDF41D27BABE770021E74D /* FlutterMock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FlutterMock.h; sourceTree = ""; }; - 98FDF41E27BABE770021E74D /* FlutterMock.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlutterMock.m; sourceTree = ""; }; + 982F2A6A27BADE17003C81F4 /* MockGMSMapView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockGMSMapView.h; sourceTree = ""; }; + 982F2A6B27BADE17003C81F4 /* MockGMSMapView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MockGMSMapView.m; sourceTree = ""; }; + 982F2A7027BAE41D003C81F4 /* GoogleMapController-Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GoogleMapController-Test.h"; sourceTree = ""; }; B7AFC65E3DD5AC60D834D83D /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; E52C6A6210A56F027C582EF9 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; EA0E91726245EDC22B97E8B9 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; @@ -190,9 +191,10 @@ F7151F11265D7ED70028CB91 /* RunnerTests */ = { isa = PBXGroup; children = ( - 98FDF41D27BABE770021E74D /* FlutterMock.h */, - 98FDF41E27BABE770021E74D /* FlutterMock.m */, + 982F2A7027BAE41D003C81F4 /* GoogleMapController-Test.h */, F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */, + 982F2A6A27BADE17003C81F4 /* MockGMSMapView.h */, + 982F2A6B27BADE17003C81F4 /* MockGMSMapView.m */, F7151F14265D7ED70028CB91 /* Info.plist */, ); path = RunnerTests; @@ -445,8 +447,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 98FDF41F27BABE770021E74D /* FlutterMock.m in Sources */, F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */, + 982F2A6C27BADE17003C81F4 /* MockGMSMapView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h deleted file mode 100644 index f2e6c5a95c01..000000000000 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -@import Foundation; -@import Flutter; - -NS_ASSUME_NONNULL_BEGIN - -@interface MockRegistrar : NSObject -@end - -@interface MockBinaryMessenger : NSObject -@end - -@interface MockTextureRegistry : NSObject -@end - -NS_ASSUME_NONNULL_END diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m deleted file mode 100644 index f55038a03024..000000000000 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/FlutterMock.m +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#import "FlutterMock.h" - -@implementation MockRegistrar - -- (void)addApplicationDelegate:(nonnull NSObject *)delegate { -} - -- (void)addMethodCallDelegate:(nonnull NSObject *)delegate - channel:(nonnull FlutterMethodChannel *)channel { -} - -- (nonnull NSString *)lookupKeyForAsset:(nonnull NSString *)asset { - return @""; -} - -- (nonnull NSString *)lookupKeyForAsset:(nonnull NSString *)asset - fromPackage:(nonnull NSString *)package { - return @""; -} - -- (nonnull NSObject *)messenger { - return [[MockBinaryMessenger alloc] init]; -} - -- (void)publish:(nonnull NSObject *)value { -} - -- (void)registerViewFactory:(nonnull NSObject *)factory - withId:(nonnull NSString *)factoryId { -} - -- (void)registerViewFactory:(nonnull NSObject *)factory - withId:(nonnull NSString *)factoryId - gestureRecognizersBlockingPolicy: - (FlutterPlatformViewGestureRecognizersBlockingPolicy)gestureRecognizersBlockingPolicy { -} - -- (nonnull NSObject *)textures { - return [[MockTextureRegistry alloc] init]; -} - -@end - -@implementation MockBinaryMessenger - -- (void)cleanUpConnection:(FlutterBinaryMessengerConnection)connection { -} - -- (void)sendOnChannel:(nonnull NSString *)channel message:(NSData *_Nullable)message { -} - -- (void)sendOnChannel:(nonnull NSString *)channel - message:(NSData *_Nullable)message - binaryReply:(FlutterBinaryReply _Nullable)callback { -} - -- (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(nonnull NSString *)channel - binaryMessageHandler: - (FlutterBinaryMessageHandler _Nullable)handler { - return 0; -} - -@end - -@implementation MockTextureRegistry - -- (int64_t)registerTexture:(nonnull NSObject *)texture { - return 0; -} - -- (void)textureFrameAvailable:(int64_t)textureId { -} - -- (void)unregisterTexture:(int64_t)textureId { -} - -@end diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapController-Test.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapController-Test.h new file mode 100644 index 000000000000..31d0c32a06a3 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapController-Test.h @@ -0,0 +1,19 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface FLTGoogleMapController (Test) + +- (instancetype)initWithMapView:(GMSMapView *)mapView + viewIdentifier:(int64_t)viewId + arguments:(id _Nullable)args + registrar:(NSObject *)registrar; + +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m index a7e1d9577773..7ce013688b35 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m @@ -5,7 +5,9 @@ @import google_maps_flutter; @import XCTest; -#import "FlutterMock.h" +#import +#import "GoogleMapController-Test.h" +#import "MockGMSMapView.h" @interface GoogleMapsTests : XCTestCase @end @@ -17,26 +19,24 @@ - (void)testPlugin { XCTAssertNotNil(plugin); } -- (void)testObserveCamera { - XCTestExpectation *viewExpectation = [self expectationWithDescription:@"View loaded"]; - - dispatch_async(dispatch_queue_create("", 0), ^{ - [self waitForExpectations:@[ viewExpectation ] timeout:1]; - }); - - MockRegistrar *object = [[MockRegistrar alloc] init]; - FLTGoogleMapController *controller = - [[FLTGoogleMapController alloc] initWithFrame:CGRectMake(0, 0, 100, 100) - viewIdentifier:0 - arguments:@{} - registrar:object]; - - for (NSInteger i = 0; i < 10000; ++i) { +- (void)testFrameObserver { + id registrar = OCMProtocolMock(@protocol(FlutterPluginRegistrar)); + CGRect frame = CGRectMake(0, 0, 100, 100); + MockGMSMapView *mapView = [[MockGMSMapView alloc] + initWithFrame:frame + camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; + FLTGoogleMapController *controller = [[FLTGoogleMapController alloc] initWithMapView:mapView + viewIdentifier:0 + arguments:nil + registrar:registrar]; + + for (NSInteger i = 0; i < 10; ++i) { [controller view]; } - [[controller view] setValue:[NSValue valueWithCGRect:CGRectMake(0, 0, 0, 0)] forKey:@"frame"]; + XCTAssertEqual(mapView.frameObserverCount, 1); - [viewExpectation fulfill]; + mapView.frame = frame; + XCTAssertEqual(mapView.frameObserverCount, 0); } @end diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h new file mode 100644 index 000000000000..098cf55c404e --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h @@ -0,0 +1,15 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +@import GoogleMaps; + +NS_ASSUME_NONNULL_BEGIN + +@interface MockGMSMapView : GMSMapView + +@property(nonatomic, assign) NSInteger frameObserverCount; + +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m new file mode 100644 index 000000000000..1d36df79a466 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m @@ -0,0 +1,28 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "MockGMSMapView.h" + +@implementation MockGMSMapView + +- (void)addObserver:(NSObject *)observer + forKeyPath:(NSString *)keyPath + options:(NSKeyValueObservingOptions)options + context:(void *)context { + [super addObserver:observer forKeyPath:keyPath options:options context:context]; + + if ([keyPath isEqualToString:@"frame"]) { + ++self.frameObserverCount; + } +} + +- (void)removeObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath { + [super removeObserver:observer forKeyPath:keyPath]; + + if ([keyPath isEqualToString:@"frame"]) { + --self.frameObserverCount; + } +} + +@end diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m index 60a78c4f407f..bb2373c1b0ef 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m @@ -62,11 +62,19 @@ - (instancetype)initWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id _Nullable)args registrar:(NSObject *)registrar { + GMSCameraPosition *camera = ToOptionalCameraPosition(args[@"initialCameraPosition"]); + GMSMapView *mapView = [GMSMapView mapWithFrame:frame camera:camera]; + return [self initWithMapView:mapView viewIdentifier:viewId arguments:args registrar:registrar]; +} + +- (instancetype)initWithMapView:(GMSMapView *_Nonnull)mapView + viewIdentifier:(int64_t)viewId + arguments:(id _Nullable)args + registrar:(NSObject *_Nonnull)registrar { if (self = [super init]) { + _mapView = mapView; _viewId = viewId; - GMSCameraPosition *camera = ToOptionalCameraPosition(args[@"initialCameraPosition"]); - _mapView = [GMSMapView mapWithFrame:frame camera:camera]; _mapView.accessibilityElementsHidden = NO; _trackCameraPosition = NO; InterpretMapOptions(args[@"options"], self); From cb7f8f4ac1ecabf6f7413af5bebf3e5ca97143ba Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Tue, 15 Feb 2022 09:12:35 +0100 Subject: [PATCH 09/19] Clean code --- .../example/ios/RunnerTests/MockGMSMapView.h | 6 +----- .../example/ios/RunnerTests/MockGMSMapView.m | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h index 098cf55c404e..7cf0bb037f39 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h @@ -4,12 +4,8 @@ @import GoogleMaps; -NS_ASSUME_NONNULL_BEGIN - @interface MockGMSMapView : GMSMapView -@property(nonatomic, assign) NSInteger frameObserverCount; +@property(nonatomic, assign, readonly) NSInteger frameObserverCount; @end - -NS_ASSUME_NONNULL_END diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m index 1d36df79a466..08b3980cc409 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m @@ -4,6 +4,12 @@ #import "MockGMSMapView.h" +@interface MockGMSMapView () + +@property(nonatomic, assign) NSInteger frameObserverCount; + +@end + @implementation MockGMSMapView - (void)addObserver:(NSObject *)observer From f74a95a00ecf3ab0fd07570af507d1ef65fc8b96 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Tue, 1 Mar 2022 11:25:22 +0100 Subject: [PATCH 10/19] Create modulemap and move test class --- .../example/ios/Runner.xcodeproj/project.pbxproj | 6 +++--- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../example/ios/RunnerTests/GoogleMapsTests.m | 2 +- .../Classes/GoogleMapController_Test.h} | 0 .../ios/Classes/google_maps_flutter-umbrella.h | 9 +++++++++ .../ios/Classes/google_maps_flutter.modulemap | 10 ++++++++++ .../ios/google_maps_flutter.podspec | 3 ++- 7 files changed, 26 insertions(+), 6 deletions(-) rename packages/google_maps_flutter/google_maps_flutter/{example/ios/RunnerTests/GoogleMapController-Test.h => ios/Classes/GoogleMapController_Test.h} (100%) create mode 100644 packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h create mode 100644 packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter.modulemap diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj index 7a23bf96fb5f..e6e5109887b6 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -70,7 +70,6 @@ 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 982F2A6A27BADE17003C81F4 /* MockGMSMapView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockGMSMapView.h; sourceTree = ""; }; 982F2A6B27BADE17003C81F4 /* MockGMSMapView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MockGMSMapView.m; sourceTree = ""; }; - 982F2A7027BAE41D003C81F4 /* GoogleMapController-Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GoogleMapController-Test.h"; sourceTree = ""; }; B7AFC65E3DD5AC60D834D83D /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; E52C6A6210A56F027C582EF9 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; EA0E91726245EDC22B97E8B9 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; @@ -191,7 +190,6 @@ F7151F11265D7ED70028CB91 /* RunnerTests */ = { isa = PBXGroup; children = ( - 982F2A7027BAE41D003C81F4 /* GoogleMapController-Test.h */, F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */, 982F2A6A27BADE17003C81F4 /* MockGMSMapView.h */, 982F2A6B27BADE17003C81F4 /* MockGMSMapView.m */, @@ -277,7 +275,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1100; + LastUpgradeCheck = 1320; ORGANIZATIONNAME = "The Flutter Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -519,6 +517,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -575,6 +574,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index afdb55fdfbdd..c983bfc640ff 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ -#import "GoogleMapController-Test.h" #import "MockGMSMapView.h" @interface GoogleMapsTests : XCTestCase diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapController-Test.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h similarity index 100% rename from packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapController-Test.h rename to packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h new file mode 100644 index 000000000000..3820aa824c0b --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h @@ -0,0 +1,9 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import + +FOUNDATION_EXPORT double google_maps_flutterVersionNumber; +FOUNDATION_EXPORT const unsigned char google_maps_flutterVersionString[]; diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter.modulemap b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter.modulemap new file mode 100644 index 000000000000..19513f4a7602 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter.modulemap @@ -0,0 +1,10 @@ +framework module google_maps_flutter { + umbrella header "google_maps_flutter-umbrella.h" + + export * + module * { export * } + + explicit module Test { + header "GoogleMapController_Test.h" + } +} diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/google_maps_flutter.podspec b/packages/google_maps_flutter/google_maps_flutter/ios/google_maps_flutter.podspec index f2ed5fc56ea0..e34919c30484 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/google_maps_flutter.podspec +++ b/packages/google_maps_flutter/google_maps_flutter/ios/google_maps_flutter.podspec @@ -14,8 +14,9 @@ Downloaded by pub (not CocoaPods). s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } s.source = { :http => 'https://github.com/flutter/plugins/tree/main/packages/google_maps_flutter/google_maps_flutter' } s.documentation_url = 'https://pub.dev/packages/google_maps_flutter' - s.source_files = 'Classes/**/*' + s.source_files = 'Classes/**/*.{h,m}' s.public_header_files = 'Classes/**/*.h' + s.module_map = 'Classes/google_maps_flutter.modulemap' s.dependency 'Flutter' s.dependency 'GoogleMaps' s.static_framework = true From 0529ae2ed276199e10f5696e9212f173ab1f2217 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Tue, 1 Mar 2022 11:46:02 +0100 Subject: [PATCH 11/19] PR commits --- .../google_maps_flutter/example/ios/Podfile | 2 +- .../example/ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ .../example/ios/RunnerTests/GoogleMapsTests.m | 4 ++-- .../{MockGMSMapView.h => PartiallyMockedMapView.h} | 3 ++- .../{MockGMSMapView.m => PartiallyMockedMapView.m} | 6 +++--- .../ios/Classes/GoogleMapController.m | 1 + .../ios/Classes/GoogleMapController_Test.h | 8 ++++++++ 7 files changed, 23 insertions(+), 13 deletions(-) rename packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/{MockGMSMapView.h => PartiallyMockedMapView.h} (71%) rename packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/{MockGMSMapView.m => PartiallyMockedMapView.m} (87%) diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Podfile b/packages/google_maps_flutter/google_maps_flutter/example/ios/Podfile index e767825011cf..29bfe631a3e7 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/Podfile +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Podfile @@ -32,7 +32,7 @@ target 'Runner' do target 'RunnerTests' do inherit! :search_paths - pod 'OCMock' + pod 'OCMock', '~> 3.9.1' end end diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj index e6e5109887b6..6a0466c3c6d9 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -15,7 +15,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - 982F2A6C27BADE17003C81F4 /* MockGMSMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 982F2A6B27BADE17003C81F4 /* MockGMSMapView.m */; }; + 982F2A6C27BADE17003C81F4 /* PartiallyMockedMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 982F2A6B27BADE17003C81F4 /* PartiallyMockedMapView.m */; }; F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */; }; F7151F21265D7EE50028CB91 /* GoogleMapsUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F20265D7EE50028CB91 /* GoogleMapsUITests.m */; }; FC8F35FC8CD533B128950487 /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F267F68029D1A4E2E4C572A7 /* libPods-RunnerTests.a */; }; @@ -68,8 +68,8 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 982F2A6A27BADE17003C81F4 /* MockGMSMapView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockGMSMapView.h; sourceTree = ""; }; - 982F2A6B27BADE17003C81F4 /* MockGMSMapView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MockGMSMapView.m; sourceTree = ""; }; + 982F2A6A27BADE17003C81F4 /* PartiallyMockedMapView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PartiallyMockedMapView.h; sourceTree = ""; }; + 982F2A6B27BADE17003C81F4 /* PartiallyMockedMapView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PartiallyMockedMapView.m; sourceTree = ""; }; B7AFC65E3DD5AC60D834D83D /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; E52C6A6210A56F027C582EF9 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; EA0E91726245EDC22B97E8B9 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; @@ -191,8 +191,8 @@ isa = PBXGroup; children = ( F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */, - 982F2A6A27BADE17003C81F4 /* MockGMSMapView.h */, - 982F2A6B27BADE17003C81F4 /* MockGMSMapView.m */, + 982F2A6A27BADE17003C81F4 /* PartiallyMockedMapView.h */, + 982F2A6B27BADE17003C81F4 /* PartiallyMockedMapView.m */, F7151F14265D7ED70028CB91 /* Info.plist */, ); path = RunnerTests; @@ -446,7 +446,7 @@ buildActionMask = 2147483647; files = ( F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */, - 982F2A6C27BADE17003C81F4 /* MockGMSMapView.m in Sources */, + 982F2A6C27BADE17003C81F4 /* PartiallyMockedMapView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m index da5f47032295..f03dca24fe7c 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/GoogleMapsTests.m @@ -7,7 +7,7 @@ @import XCTest; #import -#import "MockGMSMapView.h" +#import "PartiallyMockedMapView.h" @interface GoogleMapsTests : XCTestCase @end @@ -22,7 +22,7 @@ - (void)testPlugin { - (void)testFrameObserver { id registrar = OCMProtocolMock(@protocol(FlutterPluginRegistrar)); CGRect frame = CGRectMake(0, 0, 100, 100); - MockGMSMapView *mapView = [[MockGMSMapView alloc] + PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] initWithFrame:frame camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; FLTGoogleMapController *controller = [[FLTGoogleMapController alloc] initWithMapView:mapView diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h similarity index 71% rename from packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h rename to packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h index 7cf0bb037f39..817baf7ca5c1 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.h +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h @@ -4,7 +4,8 @@ @import GoogleMaps; -@interface MockGMSMapView : GMSMapView +// Defines a map view used for testing key-value observing. +@interface PartiallyMockedMapView : GMSMapView @property(nonatomic, assign, readonly) NSInteger frameObserverCount; diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.m similarity index 87% rename from packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m rename to packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.m index 08b3980cc409..202a18d128c0 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/MockGMSMapView.m +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.m @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "MockGMSMapView.h" +#import "PartiallyMockedMapView.h" -@interface MockGMSMapView () +@interface PartiallyMockedMapView () @property(nonatomic, assign) NSInteger frameObserverCount; @end -@implementation MockGMSMapView +@implementation PartiallyMockedMapView - (void)addObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m index bb2373c1b0ef..ca8068129566 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController.m @@ -148,6 +148,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath // zero. return; } + // We only observe the frame for initial setup. [_mapView removeObserver:self forKeyPath:@"frame"]; [_mapView moveCamera:[GMSCameraUpdate setCamera:_mapView.camera]]; } else { diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h index 31d0c32a06a3..dac89c02812f 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h @@ -9,6 +9,14 @@ NS_ASSUME_NONNULL_BEGIN @interface FLTGoogleMapController (Test) +/** + * Initialize a map controller with a concrete map view. + * + * @param mapView A map view that will be displayed by the controller + * @param viewId A unique identifier for the controller (unused). + * @param args Parameters for initialising the map view. + * @param registrar The plugin registrar passed from Flutter. +*/ - (instancetype)initWithMapView:(GMSMapView *)mapView viewIdentifier:(int64_t)viewId arguments:(id _Nullable)args From 672bdbd7930226c7c2245f2a72ff57bd50caedcd Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Tue, 1 Mar 2022 11:52:22 +0100 Subject: [PATCH 12/19] Fix formatting --- .../google_maps_flutter/ios/Classes/GoogleMapController_Test.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h index dac89c02812f..b61bb138c137 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN * @param viewId A unique identifier for the controller (unused). * @param args Parameters for initialising the map view. * @param registrar The plugin registrar passed from Flutter. -*/ + */ - (instancetype)initWithMapView:(GMSMapView *)mapView viewIdentifier:(int64_t)viewId arguments:(id _Nullable)args From 5a9477a940be85e88bf15bc08209794ad2bb01b3 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Tue, 1 Mar 2022 11:53:45 +0100 Subject: [PATCH 13/19] Add comment --- .../example/ios/RunnerTests/PartiallyMockedMapView.h | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h index 817baf7ca5c1..061869acd660 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h @@ -7,6 +7,7 @@ // Defines a map view used for testing key-value observing. @interface PartiallyMockedMapView : GMSMapView +/// Counts the number of times that `frame` KVO has been added @property(nonatomic, assign, readonly) NSInteger frameObserverCount; @end From a9cc1b47cf7f7d023b39b6846114fe8f934fa039 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Wed, 2 Mar 2022 10:07:37 +0100 Subject: [PATCH 14/19] Clean comment --- .../google_maps_flutter/ios/Classes/GoogleMapController_Test.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h index b61bb138c137..a118bc08a9da 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN * Initialize a map controller with a concrete map view. * * @param mapView A map view that will be displayed by the controller - * @param viewId A unique identifier for the controller (unused). + * @param viewId A unique identifier for the controller. * @param args Parameters for initialising the map view. * @param registrar The plugin registrar passed from Flutter. */ From 95f8ca382a6b36265c9025c8283618dadec59f24 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Wed, 2 Mar 2022 10:14:22 +0100 Subject: [PATCH 15/19] Fix CHANGELOG --- .../google_maps_flutter/google_maps_flutter/CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index f95c09f67f60..6de975a67182 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -1,11 +1,8 @@ -## NEXT +## 2.1.2 * Removes dependencies from `pubspec.yaml` that are only needed in `example/pubspec.yaml` * Updates Android compileSdkVersion to 31. * Internal code cleanup for stricter analysis options. - -## 2.1.2 - * Fixes iOS crash on `EXC_BAD_ACCESS KERN_PROTECTION_FAILURE` if the map frame changes long after creation. ## 2.1.1 From dbbc976ea40dda7c86b7e010c76ac77dcb83588f Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Tue, 8 Mar 2022 13:04:54 +0100 Subject: [PATCH 16/19] PR fixes --- .../google_maps_flutter/google_maps_flutter/CHANGELOG.md | 5 ++++- .../example/ios/RunnerTests/PartiallyMockedMapView.h | 8 ++++++-- .../google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h | 1 + .../ios/Classes/GoogleMapController_Test.h | 2 +- .../google_maps_flutter/google_maps_flutter/pubspec.yaml | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index 6de975a67182..f05de47b3036 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -1,9 +1,12 @@ +## 2.1.3 + +* Fixes iOS crash on `EXC_BAD_ACCESS KERN_PROTECTION_FAILURE` if the map frame changes long after creation. + ## 2.1.2 * Removes dependencies from `pubspec.yaml` that are only needed in `example/pubspec.yaml` * Updates Android compileSdkVersion to 31. * Internal code cleanup for stricter analysis options. -* Fixes iOS crash on `EXC_BAD_ACCESS KERN_PROTECTION_FAILURE` if the map frame changes long after creation. ## 2.1.1 diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h index 061869acd660..4288401cf90d 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h @@ -4,10 +4,14 @@ @import GoogleMaps; -// Defines a map view used for testing key-value observing. +/** + * Defines a map view used for testing key-value observing. + */ @interface PartiallyMockedMapView : GMSMapView -/// Counts the number of times that `frame` KVO has been added +/** + * The number of times that the `frame` KVO has been added. + */ @property(nonatomic, assign, readonly) NSInteger frameObserverCount; @end diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h index 953c0557ff20..cbc44bcff448 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h @@ -4,6 +4,7 @@ #import #import +#import "FLTGoogleMapTileOverlayController.h" #import "GoogleMapCircleController.h" #import "GoogleMapController.h" #import "GoogleMapMarkerController.h" diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h index a118bc08a9da..84f6f7ca485f 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN @interface FLTGoogleMapController (Test) /** - * Initialize a map controller with a concrete map view. + * Initializes a map controller with a concrete map view. * * @param mapView A map view that will be displayed by the controller * @param viewId A unique identifier for the controller. diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 849019cbdb2d..741fe6910037 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. repository: https://github.com/flutter/plugins/tree/main/packages/google_maps_flutter/google_maps_flutter issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.1.2 +version: 2.1.3 environment: sdk: ">=2.14.0 <3.0.0" From f2d83f34f2e8269e69660cae20d1802509f1d995 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Thu, 10 Mar 2022 11:58:58 +0100 Subject: [PATCH 17/19] Add JsonConversions.h to plugin header --- .../google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h index cbc44bcff448..b7e149233a65 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h @@ -10,6 +10,7 @@ #import "GoogleMapMarkerController.h" #import "GoogleMapPolygonController.h" #import "GoogleMapPolylineController.h" +#import "JsonConversions.h" @interface FLTGoogleMapsPlugin : NSObject @end From 9c39b5eda530cf46f75910c5acf7bbd4231c69f5 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Thu, 10 Mar 2022 12:04:39 +0100 Subject: [PATCH 18/19] Move headers to umbrella --- .../google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h | 2 -- .../ios/Classes/google_maps_flutter-umbrella.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h index b7e149233a65..953c0557ff20 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/FLTGoogleMapsPlugin.h @@ -4,13 +4,11 @@ #import #import -#import "FLTGoogleMapTileOverlayController.h" #import "GoogleMapCircleController.h" #import "GoogleMapController.h" #import "GoogleMapMarkerController.h" #import "GoogleMapPolygonController.h" #import "GoogleMapPolylineController.h" -#import "JsonConversions.h" @interface FLTGoogleMapsPlugin : NSObject @end diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h index 3820aa824c0b..5af927f6116a 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h @@ -4,6 +4,8 @@ #import #import +#import +#import FOUNDATION_EXPORT double google_maps_flutterVersionNumber; FOUNDATION_EXPORT const unsigned char google_maps_flutterVersionString[]; From fe83a32229d3b5c9d997fff51db78f5d78a4f36c Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Sun, 20 Mar 2022 10:11:16 +0200 Subject: [PATCH 19/19] Format --- .../ios/Classes/google_maps_flutter-umbrella.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h index 5af927f6116a..50880a2b9e9d 100644 --- a/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h +++ b/packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h @@ -3,8 +3,8 @@ // found in the LICENSE file. #import -#import #import +#import #import FOUNDATION_EXPORT double google_maps_flutterVersionNumber;