[ci][image_picker][webviews_flutter] enable Xcode 12  (#3461)

diff --git a/.cirrus.yml b/.cirrus.yml
index 1f82270..b6a9c48 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -134,11 +134,12 @@
         - xvfb-run ./script/incremental_build.sh drive-examples --linux
 
 task:
+  # Xcode 12 task
   # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins
   only_if: $CIRRUS_TAG == ''
   use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true'
   osx_instance:
-    image: catalina-xcode-11.3.1-flutter
+    image: big-sur-xcode-12.3
   upgrade_script:
     - sudo gem install cocoapods
     - flutter channel stable
@@ -149,7 +150,7 @@
   activate_script: pub global activate flutter_plugin_tools
   create_simulator_script:
     - xcrun simctl list
-    - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-13-3 | xargs xcrun simctl boot
+    - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-3 | xargs xcrun simctl boot
   matrix:
     - name: build_all_plugins_ipa
       env:
@@ -162,17 +163,6 @@
         - if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi
         - flutter channel $CHANNEL
         - ./script/build_all_plugins_app.sh ios --no-codesign
-    - name: lint_darwin_plugins
-      env:
-        matrix:
-          PLUGIN_SHARDING: "--shardIndex 0 --shardCount 2"
-          PLUGIN_SHARDING: "--shardIndex 1 --shardCount 2"
-      script:
-        # TODO(jmagman): Lint macOS podspecs but skip any that fail library validation.
-        - find . -name "*.podspec" | xargs grep -l "osx" | xargs rm
-        # Skip the dummy podspecs used to placate the tool.
-        - find . -name "*_web*.podspec" -o -name "*_mac*.podspec" | xargs rm
-        - ./script/incremental_build.sh podspecs
     - name: build-ipas+drive-examples
       env:
         PATH: $PATH:/usr/local/bin
@@ -194,13 +184,46 @@
         - flutter upgrade
         - ./script/incremental_build.sh build-examples --ipa
         - ./script/incremental_build.sh drive-examples
-        - ./script/incremental_build.sh xctest --target RunnerUITests --skip $PLUGINS_TO_SKIP_XCTESTS
+        - ./script/incremental_build.sh xctest --target RunnerUITests --skip $PLUGINS_TO_SKIP_XCTESTS --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=14.3"
+
 task:
+  # Xcode 11 task
+  # TODO(cyanglaz): merge Xcode 11 task to Xcode 12 task when all the matrix can be run in Xcode 12.
   # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins
   only_if: $CIRRUS_TAG == ''
   use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true'
   osx_instance:
     image: catalina-xcode-11.3.1-flutter
+  upgrade_script:
+    - sudo gem install cocoapods
+    - flutter channel stable
+    - flutter upgrade
+    - flutter channel master
+    - flutter upgrade
+    - git fetch origin master
+  activate_script: pub global activate flutter_plugin_tools
+  create_simulator_script:
+    - xcrun simctl list
+    - xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-13-3 | xargs xcrun simctl boot
+  matrix:
+    - name: lint_darwin_plugins
+      env:
+        matrix:
+          PLUGIN_SHARDING: "--shardIndex 0 --shardCount 2"
+          PLUGIN_SHARDING: "--shardIndex 1 --shardCount 2"
+      script:
+        # TODO(jmagman): Lint macOS podspecs but skip any that fail library validation.
+        - find . -name "*.podspec" | xargs grep -l "osx" | xargs rm
+        # Skip the dummy podspecs used to placate the tool.
+        - find . -name "*_web*.podspec" -o -name "*_mac*.podspec" | xargs rm
+        - ./script/incremental_build.sh podspecs
+
+task:
+  # don't run on release tags since it creates O(n^2) tasks where n is the number of plugins
+  only_if: $CIRRUS_TAG == ''
+  use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true'
+  osx_instance:
+    image: big-sur-xcode-12.3
   setup_script:
     - flutter config --enable-macos-desktop
   upgrade_script:
diff --git a/packages/image_picker/image_picker/CHANGELOG.md b/packages/image_picker/image_picker/CHANGELOG.md
index 1b3146d..1a09758 100644
--- a/packages/image_picker/image_picker/CHANGELOG.md
+++ b/packages/image_picker/image_picker/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.6.7+22
+
+* iOS: update XCUITests to separate each test session.
+
 ## 0.6.7+21
 
 * Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets.
diff --git a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m
index 74df795..e30fabd 100644
--- a/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m
+++ b/packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m
@@ -16,6 +16,7 @@
 @implementation ImagePickerFromGalleryUITests
 
 - (void)setUp {
+  [super setUp];
   // Delete the app if already exists, to test permission popups
 
   self.continueAfterFailure = NO;
@@ -31,7 +32,7 @@
                                             if (![allPhotoPermission waitForExistenceWithTimeout:
                                                                          kElementWaitingTime]) {
                                               os_log_error(OS_LOG_DEFAULT, "%@",
-                                                           self.app.debugDescription);
+                                                           weakSelf.app.debugDescription);
                                               XCTFail(@"Failed due to not able to find "
                                                       @"allPhotoPermission button with %@ seconds",
                                                       @(kElementWaitingTime));
@@ -42,7 +43,7 @@
                                             if (![ok waitForExistenceWithTimeout:
                                                          kElementWaitingTime]) {
                                               os_log_error(OS_LOG_DEFAULT, "%@",
-                                                           self.app.debugDescription);
+                                                           weakSelf.app.debugDescription);
                                               XCTFail(@"Failed due to not able to find ok button "
                                                       @"with %@ seconds",
                                                       @(kElementWaitingTime));
@@ -53,11 +54,19 @@
                                         }];
 }
 
+- (void)tearDown {
+  [super tearDown];
+  [self.app terminate];
+}
+
 - (void)testPickingFromGallery {
-  [self launchPickerAndCancel];
   [self launchPickerAndPick];
 }
 
+- (void)testCancel {
+  [self launchPickerAndCancel];
+}
+
 - (void)launchPickerAndCancel {
   // Find and tap on the pick from gallery button.
   NSPredicate* predicateToFindImageFromGalleryButton =
@@ -160,6 +169,10 @@
   XCTAssertTrue(pickButton.exists);
   [pickButton tap];
 
+  // There is a known bug where the permission popups interruption won't get fired until a tap
+  // happened in the app. We expect a permission popup so we do a tap here.
+  [self.app tap];
+
   // Find an image and tap on it. (IOS 14 UI, images are showing directly)
   XCUIElement* aImage;
   if (@available(iOS 14, *)) {
@@ -177,6 +190,7 @@
                                                 identifier:@"PhotosGridView"]
                  .cells.firstMatch;
   }
+  os_log_error(OS_LOG_DEFAULT, "description before picking image %@", self.app.debugDescription);
   if (![aImage waitForExistenceWithTimeout:kElementWaitingTime]) {
     os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription);
     XCTFail(@"Failed due to not able to find an image with %@ seconds", @(kElementWaitingTime));
diff --git a/packages/image_picker/image_picker/pubspec.yaml b/packages/image_picker/image_picker/pubspec.yaml
index 789ca13..075c906 100755
--- a/packages/image_picker/image_picker/pubspec.yaml
+++ b/packages/image_picker/image_picker/pubspec.yaml
@@ -2,7 +2,7 @@
 description: Flutter plugin for selecting images from the Android and iOS image
   library, and taking new pictures with the camera.
 homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker
-version: 0.6.7+21
+version: 0.6.7+22
 
 flutter:
   plugin:
diff --git a/packages/webview_flutter/CHANGELOG.md b/packages/webview_flutter/CHANGELOG.md
index 867ea17..9c54b4c 100644
--- a/packages/webview_flutter/CHANGELOG.md
+++ b/packages/webview_flutter/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.0.0-nullsafety.4
+
+* Update integration test to workaround an iOS 14 issue with `evaluateJavascript`.
+
 ## 2.0.0-nullsafety.3
 
 * Fix `onWebResourceError` on iOS.
diff --git a/packages/webview_flutter/example/integration_test/webview_flutter_test.dart b/packages/webview_flutter/example/integration_test/webview_flutter_test.dart
index 5f39cc3..50af77f 100644
--- a/packages/webview_flutter/example/integration_test/webview_flutter_test.dart
+++ b/packages/webview_flutter/example/integration_test/webview_flutter_test.dart
@@ -144,7 +144,11 @@
     await pageLoaded.future;
 
     expect(messagesReceived, isEmpty);
-    await controller.evaluateJavascript('Echo.postMessage("hello");');
+    // Append a return value "1" in the end will prevent an iOS platform exception.
+    // See: https://github.com/flutter/flutter/issues/66318#issuecomment-701105380
+    // TODO(cyanglaz): remove the workaround "1" in the end when the below issue is fixed.
+    // https://github.com/flutter/flutter/issues/66318
+    await controller.evaluateJavascript('Echo.postMessage("hello");1;');
     expect(messagesReceived, equals(<String>['hello']));
   });
 
diff --git a/packages/webview_flutter/pubspec.yaml b/packages/webview_flutter/pubspec.yaml
index 8bdd790..11769ac 100644
--- a/packages/webview_flutter/pubspec.yaml
+++ b/packages/webview_flutter/pubspec.yaml
@@ -1,6 +1,6 @@
 name: webview_flutter
 description: A Flutter plugin that provides a WebView widget on Android and iOS.
-version: 2.0.0-nullsafety.3
+version: 2.0.0-nullsafety.4
 homepage: https://github.com/flutter/plugins/tree/master/packages/webview_flutter
 
 environment: