Skip to content

Commit e391a79

Browse files
authored
[file_selector_ios] Drop deprecated UIDocumentPickerMode code path (#13292)
``` FileSelectorTests.swift:33:18: error: 'init(documentTypes:in:)' was deprecated in iOS 14.0 FileSelectorTests.swift:33:72: error: 'UIDocumentPickerMode' was deprecated in iOS 14.0: Use appropriate initializers instead ``` `init(forOpeningContentTypes:asCopy: true)` is equivalent to the previous `.import` mode. Update to Flutter 3.47 which also picks up the iOS 15 minimum. Remove old availability checks. This wasn't showing up in CI due to flutter/flutter#194517. Fixes flutter/flutter#128713 ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent d73117f commit e391a79

8 files changed

Lines changed: 21 additions & 13 deletions

File tree

‎packages/file_selector/file_selector/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
## NEXT
22

33
* Updates minimum supported SDK version to Flutter 3.41/Dart 3.11.
4+
* Updates README to reflect that the latest version of `file_selector_ios`
5+
requires iOS 15.
6+
* Applications built with older versions of Flutter will continue to use
7+
compatible versions of the platform implementation.
48

59
## 1.1.0
610

‎packages/file_selector/file_selector/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A Flutter plugin that manages files and interactions with file dialogs.
88

99
| | Android | iOS | Linux | macOS | Web | Windows |
1010
|-------------|---------|---------|-------|--------|-----|-------------|
11-
| **Support** | SDK 24+ | iOS 13+ | Any | 10.15+ | Any | Windows 10+ |
11+
| **Support** | SDK 24+ | iOS 15+ | Any | 10.15+ | Any | Windows 10+ |
1212

1313
## Setup
1414

‎packages/file_selector/file_selector_ios/CHANGELOG.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## NEXT
1+
## 0.5.3+7
22

3-
* Updates minimum supported SDK version to Flutter 3.41/Dart 3.11.
3+
* Updates minimum supported SDK version to Flutter 3.47/Dart 3.13.
4+
* Updates minimum iOS version to 15.
5+
* Replaces the `UIDocumentPickerViewController` initializer deprecated in iOS 14.
46

57
## 0.5.3+6
68

‎packages/file_selector/file_selector_ios/example/ios/RunnerTests/FileSelectorTests.swift‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import Flutter
66
import Testing
7+
import UniformTypeIdentifiers
78

89
@testable import file_selector_ios
910

@@ -30,7 +31,7 @@ final class StubViewPresenterProvider: ViewPresenterProvider {
3031
let presenter = TestViewPresenter()
3132
let plugin = FileSelectorPlugin(
3233
viewPresenterProvider: StubViewPresenterProvider(viewPresenter: presenter))
33-
let picker = UIDocumentPickerViewController(documentTypes: [], in: UIDocumentPickerMode.import)
34+
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.item], asCopy: true)
3435
plugin.documentPickerViewControllerOverride = picker
3536

3637
plugin.openFile(
@@ -45,7 +46,7 @@ final class StubViewPresenterProvider: ViewPresenterProvider {
4546
@Test func returnsPickedFiles() async throws {
4647
let plugin = FileSelectorPlugin(
4748
viewPresenterProvider: StubViewPresenterProvider(viewPresenter: TestViewPresenter()))
48-
let picker = UIDocumentPickerViewController(documentTypes: [], in: UIDocumentPickerMode.import)
49+
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.item], asCopy: true)
4950
plugin.documentPickerViewControllerOverride = picker
5051

5152
try await confirmation("completion") { completionWasCalled in
@@ -71,7 +72,7 @@ final class StubViewPresenterProvider: ViewPresenterProvider {
7172
@Test func cancellingPickerReturnsEmptyList() async throws {
7273
let plugin = FileSelectorPlugin(
7374
viewPresenterProvider: StubViewPresenterProvider(viewPresenter: TestViewPresenter()))
74-
let picker = UIDocumentPickerViewController(documentTypes: [], in: UIDocumentPickerMode.import)
75+
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.item], asCopy: true)
7576
plugin.documentPickerViewControllerOverride = picker
7677

7778
try await confirmation("completion") { completionWasCalled in

‎packages/file_selector/file_selector_ios/ios/file_selector_ios.podspec‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Displays the native iOS document picker.
1515
s.source = { :http => 'https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_ios' }
1616
s.source_files = 'file_selector_ios/Sources/file_selector_ios/**/*.swift'
1717
s.dependency 'Flutter'
18-
s.platform = :ios, '13.0'
18+
s.platform = :ios, '15.0'
1919
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
2020
s.swift_version = '5.0'
2121
s.xcconfig = {

‎packages/file_selector/file_selector_ios/ios/file_selector_ios/Package.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import PackageDescription
1010
let package = Package(
1111
name: "file_selector_ios",
1212
platforms: [
13-
.iOS("13.0")
13+
.iOS("15.0")
1414
],
1515
products: [
1616
.library(name: "file-selector-ios", targets: ["file_selector_ios"])

‎packages/file_selector/file_selector_ios/ios/file_selector_ios/Sources/file_selector_ios/FileSelectorPlugin.swift‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import Flutter
66
import ObjectiveC
77
import UIKit
8+
import UniformTypeIdentifiers
89

910
/// Bridge between a UIDocumentPickerViewController and its Pigeon callback.
1011
class PickerCompletionBridge: NSObject, UIDocumentPickerDelegate {
@@ -64,8 +65,8 @@ public class FileSelectorPlugin: NSObject, FlutterPlugin, FileSelectorApi {
6465
let documentPicker =
6566
documentPickerViewControllerOverride
6667
?? UIDocumentPickerViewController(
67-
documentTypes: config.utis,
68-
in: .import)
68+
forOpeningContentTypes: config.utis.compactMap { UTType($0) },
69+
asCopy: true)
6970
documentPicker.allowsMultipleSelection = config.allowMultiSelection
7071
documentPicker.delegate = completionBridge
7172

‎packages/file_selector/file_selector_ios/pubspec.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ 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.3+6
5+
version: 0.5.3+7
66

77
environment:
8-
sdk: ^3.11.0
9-
flutter: ">=3.41.0"
8+
sdk: ^3.13.0
9+
flutter: ">=3.47.0"
1010

1111
flutter:
1212
plugin:

0 commit comments

Comments
 (0)