Skip to content

Commit 87cdab2

Browse files
[file_selector] Updates iOS to Pigeon 13 (flutter#5268)
Picks up several breaking changes, including the switch to unwrapped BOOL properties.
1 parent 7dff4f1 commit 87cdab2

File tree

8 files changed

+55
-31
lines changed

8 files changed

+55
-31
lines changed

packages/file_selector/file_selector_ios/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.1+7
2+
3+
* Updates to Pigeon 13.
4+
15
## 0.5.1+6
26

37
* Adds pub topics to package metadata.

packages/file_selector/file_selector_ios/example/ios/RunnerTests/FileSelectorTests.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ - (void)testPickerPresents {
2323
plugin.documentPickerViewControllerOverride = picker;
2424
plugin.presentingViewControllerOverride = mockPresentingVC;
2525

26-
[plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[]
27-
allowMultiSelection:@NO]
26+
[plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[] allowMultiSelection:NO]
2827
completion:^(NSArray<NSString *> *paths, FlutterError *error){
2928
}];
3029

@@ -42,7 +41,7 @@ - (void)testReturnsPickedFiles {
4241
inMode:UIDocumentPickerModeImport];
4342
plugin.documentPickerViewControllerOverride = picker;
4443
[plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[]
45-
allowMultiSelection:@YES]
44+
allowMultiSelection:YES]
4645
completion:^(NSArray<NSString *> *paths, FlutterError *error) {
4746
NSArray *expectedPaths = @[ @"/file1.txt", @"/file2.txt" ];
4847
XCTAssertEqualObjects(paths, expectedPaths);
@@ -63,8 +62,7 @@ - (void)testCancellingPickerReturnsNil {
6362
plugin.documentPickerViewControllerOverride = picker;
6463

6564
XCTestExpectation *completionWasCalled = [self expectationWithDescription:@"completion"];
66-
[plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[]
67-
allowMultiSelection:@NO]
65+
[plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[] allowMultiSelection:NO]
6866
completion:^(NSArray<NSString *> *paths, FlutterError *error) {
6967
XCTAssertEqual(paths.count, 0);
7068
[completionWasCalled fulfill];

packages/file_selector/file_selector_ios/ios/Classes/FFSFileSelectorPlugin.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ - (void)openFileSelectorWithConfig:(FFSFileSelectorConfig *)config
2121
initWithDocumentTypes:config.utis
2222
inMode:UIDocumentPickerModeImport];
2323
documentPicker.delegate = self;
24-
documentPicker.allowsMultipleSelection = config.allowMultiSelection.boolValue;
24+
documentPicker.allowsMultipleSelection = config.allowMultiSelection;
2525

2626
UIViewController *presentingVC =
2727
self.presentingViewControllerOverride
@@ -41,7 +41,7 @@ - (void)openFileSelectorWithConfig:(FFSFileSelectorConfig *)config
4141

4242
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
4343
FFSFileSelectorPlugin *plugin = [[FFSFileSelectorPlugin alloc] init];
44-
FFSFileSelectorApiSetup(registrar.messenger, plugin);
44+
SetUpFFSFileSelectorApi(registrar.messenger, plugin);
4545
}
4646

4747
#pragma mark - UIDocumentPickerDelegate

packages/file_selector/file_selector_ios/ios/Classes/messages.g.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// Autogenerated from Pigeon (v9.2.4), do not edit directly.
4+
// Autogenerated from Pigeon (v13.0.0), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66

77
#import <Foundation/Foundation.h>
@@ -19,9 +19,9 @@ NS_ASSUME_NONNULL_BEGIN
1919
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
2020
- (instancetype)init NS_UNAVAILABLE;
2121
+ (instancetype)makeWithUtis:(NSArray<NSString *> *)utis
22-
allowMultiSelection:(NSNumber *)allowMultiSelection;
23-
@property(nonatomic, strong) NSArray<NSString *> *utis;
24-
@property(nonatomic, strong) NSNumber *allowMultiSelection;
22+
allowMultiSelection:(BOOL)allowMultiSelection;
23+
@property(nonatomic, copy) NSArray<NSString *> *utis;
24+
@property(nonatomic, assign) BOOL allowMultiSelection;
2525
@end
2626

2727
/// The codec used by FFSFileSelectorApi.
@@ -33,7 +33,7 @@ NSObject<FlutterMessageCodec> *FFSFileSelectorApiGetCodec(void);
3333
FlutterError *_Nullable))completion;
3434
@end
3535

36-
extern void FFSFileSelectorApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
36+
extern void SetUpFFSFileSelectorApi(id<FlutterBinaryMessenger> binaryMessenger,
3737
NSObject<FFSFileSelectorApi> *_Nullable api);
3838

3939
NS_ASSUME_NONNULL_END

packages/file_selector/file_selector_ios/ios/Classes/messages.g.m

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// Autogenerated from Pigeon (v9.2.4), do not edit directly.
4+
// Autogenerated from Pigeon (v13.0.0), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66

77
#import "messages.g.h"
8+
9+
#if TARGET_OS_OSX
10+
#import <FlutterMacOS/FlutterMacOS.h>
11+
#else
812
#import <Flutter/Flutter.h>
13+
#endif
914

1015
#if !__has_feature(objc_arc)
1116
#error File requires ARC to be enabled.
@@ -32,7 +37,7 @@ - (NSArray *)toList;
3237

3338
@implementation FFSFileSelectorConfig
3439
+ (instancetype)makeWithUtis:(NSArray<NSString *> *)utis
35-
allowMultiSelection:(NSNumber *)allowMultiSelection {
40+
allowMultiSelection:(BOOL)allowMultiSelection {
3641
FFSFileSelectorConfig *pigeonResult = [[FFSFileSelectorConfig alloc] init];
3742
pigeonResult.utis = utis;
3843
pigeonResult.allowMultiSelection = allowMultiSelection;
@@ -41,18 +46,16 @@ + (instancetype)makeWithUtis:(NSArray<NSString *> *)utis
4146
+ (FFSFileSelectorConfig *)fromList:(NSArray *)list {
4247
FFSFileSelectorConfig *pigeonResult = [[FFSFileSelectorConfig alloc] init];
4348
pigeonResult.utis = GetNullableObjectAtIndex(list, 0);
44-
NSAssert(pigeonResult.utis != nil, @"");
45-
pigeonResult.allowMultiSelection = GetNullableObjectAtIndex(list, 1);
46-
NSAssert(pigeonResult.allowMultiSelection != nil, @"");
49+
pigeonResult.allowMultiSelection = [GetNullableObjectAtIndex(list, 1) boolValue];
4750
return pigeonResult;
4851
}
4952
+ (nullable FFSFileSelectorConfig *)nullableFromList:(NSArray *)list {
5053
return (list) ? [FFSFileSelectorConfig fromList:list] : nil;
5154
}
5255
- (NSArray *)toList {
5356
return @[
54-
(self.utis ?: [NSNull null]),
55-
(self.allowMultiSelection ?: [NSNull null]),
57+
self.utis ?: [NSNull null],
58+
@(self.allowMultiSelection),
5659
];
5760
}
5861
@end
@@ -105,11 +108,11 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data {
105108
return sSharedObject;
106109
}
107110

108-
void FFSFileSelectorApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
111+
void SetUpFFSFileSelectorApi(id<FlutterBinaryMessenger> binaryMessenger,
109112
NSObject<FFSFileSelectorApi> *api) {
110113
{
111114
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
112-
initWithName:@"dev.flutter.pigeon.FileSelectorApi.openFile"
115+
initWithName:@"dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile"
113116
binaryMessenger:binaryMessenger
114117
codec:FFSFileSelectorApiGetCodec()];
115118
if (api) {

packages/file_selector/file_selector_ios/lib/src/messages.g.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// Autogenerated from Pigeon (v9.2.4), do not edit directly.
4+
// Autogenerated from Pigeon (v13.0.0), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66
// 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
77

@@ -11,6 +11,17 @@ import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
1111
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
1212
import 'package:flutter/services.dart';
1313

14+
List<Object?> wrapResponse(
15+
{Object? result, PlatformException? error, bool empty = false}) {
16+
if (empty) {
17+
return <Object?>[];
18+
}
19+
if (error == null) {
20+
return <Object?>[result];
21+
}
22+
return <Object?>[error.code, error.message, error.details];
23+
}
24+
1425
class FileSelectorConfig {
1526
FileSelectorConfig({
1627
required this.utis,
@@ -72,7 +83,7 @@ class FileSelectorApi {
7283

7384
Future<List<String?>> openFile(FileSelectorConfig arg_config) async {
7485
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
75-
'dev.flutter.pigeon.FileSelectorApi.openFile', codec,
86+
'dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile', codec,
7687
binaryMessenger: _binaryMessenger);
7788
final List<Object?>? replyList =
7889
await channel.send(<Object?>[arg_config]) as List<Object?>?;

packages/file_selector/file_selector_ios/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: file_selector_ios
22
description: iOS implementation of the file_selector plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_ios
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
5-
version: 0.5.1+6
5+
version: 0.5.1+7
66

77
environment:
88
sdk: ">=2.19.0 <4.0.0"
@@ -26,7 +26,7 @@ dev_dependencies:
2626
flutter_test:
2727
sdk: flutter
2828
mockito: 5.4.1
29-
pigeon: ^9.2.4
29+
pigeon: ^13.0.0
3030

3131
topics:
3232
- files

packages/file_selector/file_selector_ios/test/test_api.g.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// Autogenerated from Pigeon (v9.2.4), do not edit directly.
4+
// Autogenerated from Pigeon (v13.0.0), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import
77
// ignore_for_file: avoid_relative_lib_imports
@@ -47,7 +47,8 @@ abstract class TestFileSelectorApi {
4747
{BinaryMessenger? binaryMessenger}) {
4848
{
4949
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
50-
'dev.flutter.pigeon.FileSelectorApi.openFile', codec,
50+
'dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile',
51+
codec,
5152
binaryMessenger: binaryMessenger);
5253
if (api == null) {
5354
_testBinaryMessengerBinding!.defaultBinaryMessenger
@@ -57,14 +58,21 @@ abstract class TestFileSelectorApi {
5758
.setMockDecodedMessageHandler<Object?>(channel,
5859
(Object? message) async {
5960
assert(message != null,
60-
'Argument for dev.flutter.pigeon.FileSelectorApi.openFile was null.');
61+
'Argument for dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile was null.');
6162
final List<Object?> args = (message as List<Object?>?)!;
6263
final FileSelectorConfig? arg_config =
6364
(args[0] as FileSelectorConfig?);
6465
assert(arg_config != null,
65-
'Argument for dev.flutter.pigeon.FileSelectorApi.openFile was null, expected non-null FileSelectorConfig.');
66-
final List<String?> output = await api.openFile(arg_config!);
67-
return <Object?>[output];
66+
'Argument for dev.flutter.pigeon.file_selector_ios.FileSelectorApi.openFile was null, expected non-null FileSelectorConfig.');
67+
try {
68+
final List<String?> output = await api.openFile(arg_config!);
69+
return <Object?>[output];
70+
} on PlatformException catch (e) {
71+
return wrapResponse(error: e);
72+
} catch (e) {
73+
return wrapResponse(
74+
error: PlatformException(code: 'error', message: e.toString()));
75+
}
6876
});
6977
}
7078
}

0 commit comments

Comments
 (0)