[pigeon] fix swift compressed list datatypes (#2963)

* fix swift compressed list datatypes

* fix casting in ios swift unit tests

* correct data creation methods for compressed lists
diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md
index 1a49043..c0db66c 100644
--- a/packages/pigeon/CHANGELOG.md
+++ b/packages/pigeon/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 4.2.11
+
+* [swift] Fixes compressed list data types.
+
 ## 4.2.10
 
 * Changes generated Java enum field to be final.
diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart
index bbe6124..526afd7 100644
--- a/packages/pigeon/lib/generator_tools.dart
+++ b/packages/pigeon/lib/generator_tools.dart
@@ -9,7 +9,7 @@
 import 'ast.dart';
 
 /// The current version of pigeon. This must match the version in pubspec.yaml.
-const String pigeonVersion = '4.2.10';
+const String pigeonVersion = '4.2.11';
 
 /// Read all the content from [stdin] to a String.
 String readStdin() {
diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart
index 92e3105..0b1442f 100644
--- a/packages/pigeon/lib/swift_generator.dart
+++ b/packages/pigeon/lib/swift_generator.dart
@@ -404,11 +404,11 @@
     'String': 'String',
     'int': 'Int32',
     'double': 'Double',
-    'Uint8List': '[UInt8]',
-    'Int32List': '[Int32]',
-    'Int64List': '[Int64]',
-    'Float32List': '[Float32]',
-    'Float64List': '[Float64]',
+    'Uint8List': 'FlutterStandardTypedData',
+    'Int32List': 'FlutterStandardTypedData',
+    'Int64List': 'FlutterStandardTypedData',
+    'Float32List': 'FlutterStandardTypedData',
+    'Float64List': 'FlutterStandardTypedData',
     'Object': 'Any',
   };
   if (swiftTypeForDartTypeMap.containsKey(type.baseName)) {
diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart
index 4e68c3a..5346472 100644
--- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart
+++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart
@@ -69,13 +69,10 @@
       expect(echoObject.anInt, sentObject.anInt);
       expect(echoObject.aDouble, sentObject.aDouble);
       expect(echoObject.aString, sentObject.aString);
-      // TODO(stuartmorgan): Enable these once they work for all generators;
-      // currently at least Swift is broken.
-      // See https://github.com/flutter/flutter/issues/115906
-      //expect(echoObject.aByteArray, sentObject.aByteArray);
-      //expect(echoObject.a4ByteArray, sentObject.a4ByteArray);
-      //expect(echoObject.a8ByteArray, sentObject.a8ByteArray);
-      //expect(echoObject.aFloatArray, sentObject.aFloatArray);
+      expect(echoObject.aByteArray, sentObject.aByteArray);
+      expect(echoObject.a4ByteArray, sentObject.a4ByteArray);
+      expect(echoObject.a8ByteArray, sentObject.a8ByteArray);
+      expect(echoObject.aFloatArray, sentObject.aFloatArray);
       expect(listEquals(echoObject.aList, sentObject.aList), true);
       expect(mapEquals(echoObject.aMap, sentObject.aMap), true);
       expect(echoObject.nestedList?.length, sentObject.nestedList?.length);
@@ -177,19 +174,26 @@
       expect(receivedString, sentString);
     });
 
-    // TODO(stuartmorgan): Enable these once they work for all generators;
-    // currently at least Swift is broken.
-    // TODO(tarrinneal): Finish tests for int lists once issue solved.
-    // See https://github.com/flutter/flutter/issues/115906
-    // testWidgets('Uint8List serialize and deserialize correctly',
-    //     (WidgetTester _) async {
-    //   final HostIntegrationCoreApi api = HostIntegrationCoreApi();
-    //   final List<int> data = [102, 111, 114, 116, 121, 45, 116, 119, 111, 0];
-    //   final Uint8List sentUint8List = Uint8List.fromList(data);
-    //   final Uint8List receivedUint8List =
-    //       await api.echoUint8List(sentUint8List);
-    //   expect(receivedUint8List, sentUint8List);
-    // });
+    testWidgets('Uint8List serialize and deserialize correctly',
+        (WidgetTester _) async {
+      final HostIntegrationCoreApi api = HostIntegrationCoreApi();
+      final List<int> data = <int>[
+        102,
+        111,
+        114,
+        116,
+        121,
+        45,
+        116,
+        119,
+        111,
+        0
+      ];
+      final Uint8List sentUint8List = Uint8List.fromList(data);
+      final Uint8List receivedUint8List =
+          await api.echoUint8List(sentUint8List);
+      expect(receivedUint8List, sentUint8List);
+    });
   });
 
   group('Host async API tests', () {
diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart
index b701c66..9b0f14b 100644
--- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart
+++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
-// Autogenerated from Pigeon (v4.2.10), do not edit directly.
+// Autogenerated from Pigeon (v4.2.11), do not edit directly.
 // See also: https://pub.dev/packages/pigeon
 // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
 import 'dart:async';
diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift
index 6229ef5..df69d27 100644
--- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift
+++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+import Flutter
 import XCTest
 @testable import test_plugin
 
@@ -40,10 +41,11 @@
       anInt: 1,
       aDouble: 2.0,
       aString: "123",
-      aByteArray: [UInt8]("1234".data(using: .utf8)!),
-      a4ByteArray: [Int32].init(arrayLiteral: 1, 2, 3, 4),
-      a8ByteArray: [Int64].init(arrayLiteral: 1, 2, 3, 4, 5, 6, 7, 8),
-      aFloatArray: [Float64].init(arrayLiteral: 1, 2, 3, 4, 5, 6, 7, 8),
+      aByteArray: FlutterStandardTypedData(bytes: "1234".data(using: .utf8)!),
+      a4ByteArray: FlutterStandardTypedData(int32: "1234".data(using: .utf8)!),
+      a8ByteArray: FlutterStandardTypedData(int64: "12345678".data(using: .utf8)!),
+      aFloatArray: FlutterStandardTypedData(float64: "12345678".data(using: .utf8)!),
+
       aList: [1, 2],
       aMap: ["hello": 1234],
       nestedList: [[true, false], [true]],
diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift
index 539feae..7740ada 100644
--- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift
+++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift
@@ -13,7 +13,7 @@
   func aDouble(value: Double) -> Double { value }
   func aMap(value: [AnyHashable: Any?]) -> [AnyHashable: Any?] { value }
   func aList(value: [Any?]) -> [Any?] { value }
-  func anInt32List(value: [Int32]) -> [Int32] { value }
+  func anInt32List(value: FlutterStandardTypedData) -> FlutterStandardTypedData { value }
   func aBoolList(value: [Bool?]) -> [Bool?] { value }
   func aStringIntMap(value: [String?: Int32?]) -> [String?: Int32?] { value }
 }
diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift
index b27bbb2..fdb4f35 100644
--- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift
+++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift
@@ -64,7 +64,7 @@
     return aString
   }
 
-  func echoUint8List(aUint8List: [UInt8]) -> [UInt8] {
+  func echoUint8List(aUint8List: FlutterStandardTypedData) -> FlutterStandardTypedData {
     return aUint8List
   }
 
diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift
index be3d518..d40fcb8 100644
--- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift
+++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift
@@ -64,7 +64,7 @@
     return aString
   }
 
-  func echoUint8List(aUint8List: [UInt8]) -> [UInt8] {
+  func echoUint8List(aUint8List: FlutterStandardTypedData) -> FlutterStandardTypedData {
     return aUint8List
   }
 
diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml
index 7f68ad1..24bc2af 100644
--- a/packages/pigeon/pubspec.yaml
+++ b/packages/pigeon/pubspec.yaml
@@ -2,7 +2,7 @@
 description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
 repository: https://github.com/flutter/packages/tree/main/packages/pigeon
 issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
-version: 4.2.10 # This must match the version in lib/generator_tools.dart
+version: 4.2.11 # This must match the version in lib/generator_tools.dart
 
 environment:
   sdk: ">=2.12.0 <3.0.0"
diff --git a/packages/pigeon/test/swift_generator_test.dart b/packages/pigeon/test/swift_generator_test.dart
index c22ddbe..cda0f48 100644
--- a/packages/pigeon/test/swift_generator_test.dart
+++ b/packages/pigeon/test/swift_generator_test.dart
@@ -187,10 +187,10 @@
     expect(code, contains('var aInt: Int32? = nil'));
     expect(code, contains('var aDouble: Double? = nil'));
     expect(code, contains('var aString: String? = nil'));
-    expect(code, contains('var aUint8List: [UInt8]? = nil'));
-    expect(code, contains('var aInt32List: [Int32]? = nil'));
-    expect(code, contains('var aInt64List: [Int64]? = nil'));
-    expect(code, contains('var aFloat64List: [Float64]? = nil'));
+    expect(code, contains('var aUint8List: FlutterStandardTypedData? = nil'));
+    expect(code, contains('var aInt32List: FlutterStandardTypedData? = nil'));
+    expect(code, contains('var aInt64List: FlutterStandardTypedData? = nil'));
+    expect(code, contains('var aFloat64List: FlutterStandardTypedData? = nil'));
   });
 
   test('gen one flutter api', () {