Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 26.1.7

* [objc] Updates to use module imports.

## 26.1.6

* Bumps kotlin_version to 2.3.0.
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/example/app/macos/Runner/messages.g.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Autogenerated from Pigeon, do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>
@import Foundation;

@protocol FlutterBinaryMessenger;
@protocol FlutterMessageCodec;
Expand Down
8 changes: 2 additions & 6 deletions packages/pigeon/example/app/macos/Runner/messages.g.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
#import "messages.g.h"

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
@import FlutterMacOS;
#else
#import <Flutter/Flutter.h>
#endif

#if !__has_feature(objc_arc)
#error File requires ARC to be enabled.
@import Flutter;
#endif

static NSArray<id> *wrapResult(id result, FlutterError *error) {
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/src/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'generator.dart';
/// The current version of pigeon.
///
/// This must match the version in pubspec.yaml.
const String pigeonVersion = '26.1.6';
const String pigeonVersion = '26.1.7';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
11 changes: 3 additions & 8 deletions packages/pigeon/lib/src/objc/objc_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class ObjcHeaderGenerator extends StructuredGenerator<InternalObjcOptions> {
Indent indent, {
required String dartPackageName,
}) {
indent.writeln('#import <Foundation/Foundation.h>');
indent.writeln('@import Foundation;');
indent.newln();

indent.writeln('@protocol FlutterBinaryMessenger;');
Expand Down Expand Up @@ -513,14 +513,9 @@ class ObjcSourceGenerator extends StructuredGenerator<InternalObjcOptions> {
indent.writeln('#import "${generatorOptions.headerIncludePath}"');
indent.newln();
indent.writeln('#if TARGET_OS_OSX');
indent.writeln('#import <FlutterMacOS/FlutterMacOS.h>');
indent.writeln('@import FlutterMacOS;');
indent.writeln('#else');
indent.writeln('#import <Flutter/Flutter.h>');
indent.writeln('#endif');
indent.newln();

indent.writeln('#if !__has_feature(objc_arc)');
indent.writeln('#error File requires ARC to be enabled.');
indent.writeln('@import Flutter;');
indent.writeln('#endif');
indent.newln();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
#import "./include/alternate_language_test_plugin/CoreTests.gen.h"

#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
@import FlutterMacOS;
#else
#import <Flutter/Flutter.h>
#endif

#if !__has_feature(objc_arc)
#error File requires ARC to be enabled.
@import Flutter;
#endif

static NSArray<id> *wrapResult(id result, FlutterError *error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Autogenerated from Pigeon, do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>
@import Foundation;

@protocol FlutterBinaryMessenger;
@protocol FlutterMessageCodec;
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.1.6 # This must match the version in lib/src/generator_tools.dart
version: 26.1.7 # This must match the version in lib/src/generator_tools.dart

environment:
sdk: ^3.9.0
Expand Down
25 changes: 25 additions & 0 deletions packages/pigeon/test/objc_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,31 @@ void main() {
expect(code, startsWith('// hello world'));
});

test('only uses new-style module imports', () {
final root = Root(apis: <Api>[], classes: <Class>[], enums: <Enum>[]);
final sink = StringBuffer();
const generator = ObjcGenerator();
final generatorOptions = OutputFileOptions<InternalObjcOptions>(
fileType: FileType.source,
languageOptions: InternalObjcOptions(
headerIncludePath: 'foo.h',
prefix: 'ABC',
copyrightHeader: makeIterable('hello world'),
objcHeaderOut: '',
objcSourceOut: '',
),
);
generator.generate(
generatorOptions,
root,
sink,
dartPackageName: DEFAULT_PACKAGE_NAME,
);
final code = sink.toString();
expect(code, contains('@import'));
expect(code, isNot(contains('#import <')));
});

test('field generics', () {
final classDefinition = Class(
name: 'Foobar',
Expand Down
Loading