diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index 3b9ee79da122..0a970248c790 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,6 +1,7 @@ ## NEXT * Updates minimum supported SDK version to Flutter 3.38/Dart 3.10. +* [swift] Adds `CaseIterable` conformance to generated enums. ## 26.3.4 diff --git a/packages/pigeon/example/app/ios/Flutter/Debug.xcconfig b/packages/pigeon/example/app/ios/Flutter/Debug.xcconfig index 592ceee85b89..ec97fc6f3021 100644 --- a/packages/pigeon/example/app/ios/Flutter/Debug.xcconfig +++ b/packages/pigeon/example/app/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/packages/pigeon/example/app/ios/Flutter/Release.xcconfig b/packages/pigeon/example/app/ios/Flutter/Release.xcconfig index 592ceee85b89..c4855bfe2000 100644 --- a/packages/pigeon/example/app/ios/Flutter/Release.xcconfig +++ b/packages/pigeon/example/app/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/packages/pigeon/example/app/ios/Podfile b/packages/pigeon/example/app/ios/Podfile new file mode 100644 index 000000000000..620e46eba607 --- /dev/null +++ b/packages/pigeon/example/app/ios/Podfile @@ -0,0 +1,43 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '13.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/pigeon/example/app/ios/Runner/Messages.g.swift b/packages/pigeon/example/app/ios/Runner/Messages.g.swift index f8b12f846c22..44b64bbc91a9 100644 --- a/packages/pigeon/example/app/ios/Runner/Messages.g.swift +++ b/packages/pigeon/example/app/ios/Runner/Messages.g.swift @@ -182,7 +182,7 @@ func deepHashMessages(value: Any?, hasher: inout Hasher) { } } -enum Code: Int { +enum Code: Int, CaseIterable { case one = 0 case two = 1 } diff --git a/packages/pigeon/example/app/macos/Flutter/Flutter-Debug.xcconfig b/packages/pigeon/example/app/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b608ba..4b81f9b2d200 100644 --- a/packages/pigeon/example/app/macos/Flutter/Flutter-Debug.xcconfig +++ b/packages/pigeon/example/app/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/pigeon/example/app/macos/Flutter/Flutter-Release.xcconfig b/packages/pigeon/example/app/macos/Flutter/Flutter-Release.xcconfig index c2efd0b608ba..5caa9d1579e4 100644 --- a/packages/pigeon/example/app/macos/Flutter/Flutter-Release.xcconfig +++ b/packages/pigeon/example/app/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/pigeon/example/app/macos/Podfile b/packages/pigeon/example/app/macos/Podfile new file mode 100644 index 000000000000..ff5ddb3b8bdc --- /dev/null +++ b/packages/pigeon/example/app/macos/Podfile @@ -0,0 +1,42 @@ +platform :osx, '10.15' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/pigeon/lib/src/generator_tools.dart b/packages/pigeon/lib/src/generator_tools.dart index 55874a95684a..c4870feba80f 100644 --- a/packages/pigeon/lib/src/generator_tools.dart +++ b/packages/pigeon/lib/src/generator_tools.dart @@ -15,7 +15,7 @@ import 'generator.dart'; /// The current version of pigeon. /// /// This must match the version in pubspec.yaml. -const String pigeonVersion = '26.3.4'; +const String pigeonVersion = '26.3.5'; /// Default plugin package name. const String defaultPluginPackageName = 'dev.flutter.pigeon'; diff --git a/packages/pigeon/lib/src/swift/swift_generator.dart b/packages/pigeon/lib/src/swift/swift_generator.dart index 45b968ed4d10..75507d0d262d 100644 --- a/packages/pigeon/lib/src/swift/swift_generator.dart +++ b/packages/pigeon/lib/src/swift/swift_generator.dart @@ -238,7 +238,7 @@ class SwiftGenerator extends StructuredGenerator { _docCommentSpec, ); - indent.write('enum ${anEnum.name}: Int '); + indent.write('enum ${anEnum.name}: Int, CaseIterable '); indent.addScoped('{', '}', () { enumerate(anEnum.members, (int index, final EnumMember member) { addDocumentationComments( diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Flutter/Debug.xcconfig b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Flutter/Debug.xcconfig index 592ceee85b89..ec97fc6f3021 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Flutter/Debug.xcconfig +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Flutter/Release.xcconfig b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Flutter/Release.xcconfig index 592ceee85b89..c4855bfe2000 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Flutter/Release.xcconfig +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Podfile b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Podfile new file mode 100644 index 000000000000..620e46eba607 --- /dev/null +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/Podfile @@ -0,0 +1,43 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '13.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Flutter/Flutter-Debug.xcconfig b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b608ba..4b81f9b2d200 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Flutter/Flutter-Debug.xcconfig +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Flutter/Flutter-Release.xcconfig b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Flutter/Flutter-Release.xcconfig index c2efd0b608ba..5caa9d1579e4 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Flutter/Flutter-Release.xcconfig +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Podfile b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Podfile new file mode 100644 index 000000000000..ff5ddb3b8bdc --- /dev/null +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/Podfile @@ -0,0 +1,42 @@ +platform :osx, '10.15' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift index 606d58783837..0fc6517a8bc0 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift @@ -183,7 +183,7 @@ func deepHashCoreTests(value: Any?, hasher: inout Hasher) { } } -enum AnEnum: Int { +enum AnEnum: Int, CaseIterable { case one = 0 case two = 1 case three = 2 @@ -191,7 +191,7 @@ enum AnEnum: Int { case fourHundredTwentyTwo = 4 } -enum AnotherEnum: Int { +enum AnotherEnum: Int, CaseIterable { case justInCase = 0 } diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/EventChannelTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/EventChannelTests.gen.swift index da3e19626382..096bc2d2892b 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/EventChannelTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/EventChannelTests.gen.swift @@ -151,7 +151,7 @@ func deepHashEventChannelTests(value: Any?, hasher: inout Hasher) { } } -enum EventEnum: Int { +enum EventEnum: Int, CaseIterable { case one = 0 case two = 1 case three = 2 @@ -159,7 +159,7 @@ enum EventEnum: Int { case fourHundredTwentyTwo = 4 } -enum AnotherEventEnum: Int { +enum AnotherEventEnum: Int, CaseIterable { case justInCase = 0 } diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift index 5eb4b81803ad..7986f398895a 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift @@ -580,7 +580,7 @@ private class ProxyApiTestsPigeonInternalProxyApiCodecReaderWriter: FlutterStand } } -enum ProxyApiTestEnum: Int { +enum ProxyApiTestEnum: Int, CaseIterable { case one = 0 case two = 1 case three = 2 diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/Flutter/Debug.xcconfig b/packages/pigeon/platform_tests/test_plugin/example/ios/Flutter/Debug.xcconfig index 592ceee85b89..ec97fc6f3021 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/Flutter/Debug.xcconfig +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/Flutter/Release.xcconfig b/packages/pigeon/platform_tests/test_plugin/example/ios/Flutter/Release.xcconfig index 592ceee85b89..c4855bfe2000 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/Flutter/Release.xcconfig +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/Podfile b/packages/pigeon/platform_tests/test_plugin/example/ios/Podfile new file mode 100644 index 000000000000..620e46eba607 --- /dev/null +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/Podfile @@ -0,0 +1,43 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '13.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/pigeon/platform_tests/test_plugin/example/macos/Flutter/Flutter-Debug.xcconfig b/packages/pigeon/platform_tests/test_plugin/example/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b608ba..4b81f9b2d200 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/macos/Flutter/Flutter-Debug.xcconfig +++ b/packages/pigeon/platform_tests/test_plugin/example/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/pigeon/platform_tests/test_plugin/example/macos/Flutter/Flutter-Release.xcconfig b/packages/pigeon/platform_tests/test_plugin/example/macos/Flutter/Flutter-Release.xcconfig index c2efd0b608ba..5caa9d1579e4 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/macos/Flutter/Flutter-Release.xcconfig +++ b/packages/pigeon/platform_tests/test_plugin/example/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/pigeon/platform_tests/test_plugin/example/macos/Podfile b/packages/pigeon/platform_tests/test_plugin/example/macos/Podfile new file mode 100644 index 000000000000..ff5ddb3b8bdc --- /dev/null +++ b/packages/pigeon/platform_tests/test_plugin/example/macos/Podfile @@ -0,0 +1,42 @@ +platform :osx, '10.15' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index 7ac94252e537..e3ce2f709b79 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -2,7 +2,7 @@ name: pigeon 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%3A%22p%3A+pigeon%22 -version: 26.3.4 # This must match the version in lib/src/generator_tools.dart +version: 26.3.5 # This must match the version in lib/src/generator_tools.dart environment: sdk: ^3.10.0