Skip to content

Commit f2c6798

Browse files
authored
[file_selector_macos] Drop deprecated allowedFileTypes code path (flutter#13302)
Update to Flutter 3.47 which also picks up the macOS 12 minimum. Remove old availability checks. Delete the `forceLegacyTypes` codepath. This wasn't showing up in CI due to flutter/flutter#194517. Fixes flutter/flutter#194573 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^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 b7efc36 commit f2c6798

9 files changed

Lines changed: 44 additions & 109 deletions

File tree

‎packages/file_selector/file_selector/CHANGELOG.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +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.
4+
* Updates README to reflect that the latest versions of `file_selector_ios`
5+
and `file_selector_macos` require iOS 15 and macOS 12.
66
* Applications built with older versions of Flutter will continue to use
7-
compatible versions of the platform implementation.
7+
compatible versions of the platform implementations.
88

99
## 1.1.0
1010

‎packages/file_selector/file_selector/README.md‎

Lines changed: 7 additions & 9 deletions
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 15+ | Any | 10.15+ | Any | Windows 10+ |
11+
| **Support** | SDK 24+ | iOS 15+ | Any | 12+ | Any | Windows 10+ |
1212

1313
## Setup
1414

@@ -97,14 +97,12 @@ Different platforms support different type group filter options. To avoid
9797
filters that cover all platforms you are targeting, or that you conditionally
9898
pass different `XTypeGroup`s based on `Platform`.
9999

100-
| | Andoid | iOS | Linux | macOS | Web | Windows |
101-
|--------------------------|--------|-----|-------|--------|-----|-------------|
102-
| `extensions` | ✔️ | | ✔️ | ✔️ | ✔️ | ✔️ |
103-
| `mimeTypes` | ✔️ | | ✔️ | ✔️† | ✔️ | |
104-
| `uniformTypeIdentifiers` | | ✔️ | | ✔️ | | |
105-
| `webWildCards` | | | | | ✔️ | |
106-
107-
† `mimeTypes` are not supported on version of macOS earlier than 11 (Big Sur).
100+
| | Android | iOS | Linux | macOS | Web | Windows |
101+
|--------------------------|---------|-----|-------|-------|-----|---------|
102+
| `extensions` | ✔️ | | ✔️ | ✔️ | ✔️ | ✔️ |
103+
| `mimeTypes` | ✔️ | | ✔️ | ✔️ | ✔️ | |
104+
| `uniformTypeIdentifiers` | | ✔️ | | ✔️ | | |
105+
| `webWildCards` | | | | | ✔️ | |
108106

109107
### Features supported by platform
110108

‎packages/file_selector/file_selector_macos/CHANGELOG.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## NEXT
1+
## 0.9.5+2
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 macOS version to 12.
5+
* Removes the macOS 10.15 code path that used the deprecated `allowedFileTypes` property.
46

57
## 0.9.5+1
68

‎packages/file_selector/file_selector_macos/example/macos/Runner.xcodeproj/project.pbxproj‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@
431431
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
432432
GCC_WARN_UNUSED_FUNCTION = YES;
433433
GCC_WARN_UNUSED_VARIABLE = YES;
434-
MACOSX_DEPLOYMENT_TARGET = 10.15;
434+
MACOSX_DEPLOYMENT_TARGET = 12.0;
435435
MTL_ENABLE_DEBUG_INFO = NO;
436436
SDKROOT = macosx;
437437
SWIFT_COMPILATION_MODE = wholemodule;
@@ -564,7 +564,7 @@
564564
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
565565
GCC_WARN_UNUSED_FUNCTION = YES;
566566
GCC_WARN_UNUSED_VARIABLE = YES;
567-
MACOSX_DEPLOYMENT_TARGET = 10.15;
567+
MACOSX_DEPLOYMENT_TARGET = 12.0;
568568
MTL_ENABLE_DEBUG_INFO = YES;
569569
ONLY_ACTIVE_ARCH = YES;
570570
SDKROOT = macosx;
@@ -611,7 +611,7 @@
611611
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
612612
GCC_WARN_UNUSED_FUNCTION = YES;
613613
GCC_WARN_UNUSED_VARIABLE = YES;
614-
MACOSX_DEPLOYMENT_TARGET = 10.15;
614+
MACOSX_DEPLOYMENT_TARGET = 12.0;
615615
MTL_ENABLE_DEBUG_INFO = NO;
616616
SDKROOT = macosx;
617617
SWIFT_COMPILATION_MODE = wholemodule;

‎packages/file_selector/file_selector_macos/example/macos/RunnerTests/RunnerTests.swift‎

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,10 @@ class TestViewProvider: NSObject, ViewProvider {
170170
}
171171

172172
let panel = try #require(panelController.openPanel)
173-
if #available(macOS 11.0, *) {
174-
#expect(panel.allowedContentTypes.contains(UTType.plainText))
175-
#expect(panel.allowedContentTypes.contains(UTType.json))
176-
#expect(panel.allowedContentTypes.contains(UTType.html))
177-
#expect(panel.allowedContentTypes.contains(UTType.image))
178-
} else {
179-
// MIME type is not supported for the legacy codepath, but the rest should be set.
180-
#expect(panel.allowedFileTypes == ["txt", "json", "public.text", "public.image"])
181-
}
173+
#expect(panel.allowedContentTypes.contains(UTType.plainText))
174+
#expect(panel.allowedContentTypes.contains(UTType.json))
175+
#expect(panel.allowedContentTypes.contains(UTType.html))
176+
#expect(panel.allowedContentTypes.contains(UTType.image))
182177
}
183178

184179
@Test func filterUnknownFileExtension() async throws {
@@ -213,61 +208,12 @@ class TestViewProvider: NSObject, ViewProvider {
213208
}
214209

215210
let panel = try #require(panelController.openPanel)
216-
if #available(macOS 11.0, *) {
217-
#expect(panel.allowedContentTypes.count == 1)
218-
let allowedType = try #require(panel.allowedContentTypes.first)
219-
#expect(allowedType.preferredFilenameExtension == unknownExtension)
220-
// If this isn't true, the dynamic type created for the extension won't work as a file
221-
// extension filter.
222-
#expect(allowedType.conforms(to: UTType.data))
223-
} else {
224-
#expect(panel.allowedFileTypes == [unknownExtension])
225-
}
226-
}
227-
228-
@Test func openWithFilterLegacy() async throws {
229-
let panelController = TestPanelController()
230-
let plugin = FileSelectorPlugin(
231-
viewProvider: TestViewProvider(),
232-
panelController: panelController)
233-
plugin.forceLegacyTypes = true
234-
235-
let returnPath = "/foo/bar"
236-
panelController.openURLs = [URL(fileURLWithPath: returnPath)]
237-
238-
await confirmation("completion") { called in
239-
let options = OpenPanelOptions(
240-
allowsMultipleSelection: true,
241-
canChooseDirectories: false,
242-
canChooseFiles: true,
243-
baseOptions: SavePanelOptions(
244-
allowedFileTypes: AllowedTypes(
245-
extensions: ["txt", "json"],
246-
mimeTypes: ["text/html"],
247-
utis: ["public.text", "public.image"])))
248-
plugin.displayOpenPanel(options: options) { result in
249-
switch result {
250-
case .success(let paths):
251-
#expect(paths == [returnPath])
252-
case .failure(let error):
253-
Issue.record("\(error)")
254-
}
255-
called()
256-
}
257-
}
258-
259-
let panel = try #require(panelController.openPanel)
260-
// On the legacy path, the allowedFileTypes should be set directly.
261-
#expect(panel.allowedFileTypes == ["txt", "json", "public.text", "public.image"])
262-
263-
// They should also be translated to corresponding allowed content types.
264-
if #available(macOS 11.0, *) {
265-
#expect(panel.allowedContentTypes.contains(UTType.plainText))
266-
#expect(panel.allowedContentTypes.contains(UTType.json))
267-
#expect(panel.allowedContentTypes.contains(UTType.image))
268-
// MIME type is not supported for the legacy codepath.
269-
#expect(!panel.allowedContentTypes.contains(UTType.html))
270-
}
211+
#expect(panel.allowedContentTypes.count == 1)
212+
let allowedType = try #require(panel.allowedContentTypes.first)
213+
#expect(allowedType.preferredFilenameExtension == unknownExtension)
214+
// If this isn't true, the dynamic type created for the extension won't work as a file
215+
// extension filter.
216+
#expect(allowedType.conforms(to: UTType.data))
271217
}
272218

273219
@Test func openCancel() async throws {

‎packages/file_selector/file_selector_macos/macos/file_selector_macos.podspec‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Displays native macOS open and save panels.
1616
s.resource_bundles = {'file_selector_macos_privacy' => ['file_selector_macos/Sources/file_selector_macos/Resources/PrivacyInfo.xcprivacy']}
1717
s.dependency 'FlutterMacOS'
1818

19-
s.platform = :osx, '10.15'
19+
s.platform = :osx, '12.0'
2020
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
2121
s.swift_version = '5.0'
2222
end

‎packages/file_selector/file_selector_macos/macos/file_selector_macos/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_macos",
1212
platforms: [
13-
.macOS("10.15")
13+
.macOS("12.0")
1414
],
1515
products: [
1616
.library(name: "file-selector-macos", targets: ["file_selector_macos"])

‎packages/file_selector/file_selector_macos/macos/file_selector_macos/Sources/file_selector_macos/FileSelectorPlugin.swift‎

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public class FileSelectorPlugin: NSObject, FlutterPlugin, FileSelectorApi {
4949
private let openDirectoryMethod = "getDirectoryPath"
5050
private let saveMethod = "getSavePath"
5151

52-
var forceLegacyTypes = false
53-
5452
public static func register(with registrar: FlutterPluginRegistrar) {
5553
let instance = FileSelectorPlugin(
5654
viewProvider: DefaultViewProvider(registrar: registrar),
@@ -105,27 +103,18 @@ public class FileSelectorPlugin: NSObject, FlutterPlugin, FileSelectorApi {
105103
}
106104

107105
if let acceptedTypes = options.allowedFileTypes {
108-
if #available(macOS 11, *), !forceLegacyTypes {
109-
var allowedTypes: [UTType] = []
110-
allowedTypes.append(contentsOf: acceptedTypes.utis.compactMap({ UTType($0) }))
111-
allowedTypes.append(
112-
contentsOf: acceptedTypes.extensions.compactMap({
113-
UTType.init(filenameExtension: $0)
114-
}))
115-
allowedTypes.append(
116-
contentsOf: acceptedTypes.mimeTypes.compactMap({
117-
UTType.init(mimeType: $0)
118-
}))
119-
if !allowedTypes.isEmpty {
120-
panel.allowedContentTypes = allowedTypes
121-
}
122-
} else {
123-
var allowedTypes: [String] = []
124-
allowedTypes.append(contentsOf: acceptedTypes.extensions.map({ $0 }))
125-
allowedTypes.append(contentsOf: acceptedTypes.utis.map({ $0 }))
126-
if !allowedTypes.isEmpty {
127-
panel.allowedFileTypes = allowedTypes
128-
}
106+
var allowedTypes: [UTType] = []
107+
allowedTypes.append(contentsOf: acceptedTypes.utis.compactMap({ UTType($0) }))
108+
allowedTypes.append(
109+
contentsOf: acceptedTypes.extensions.compactMap({
110+
UTType.init(filenameExtension: $0)
111+
}))
112+
allowedTypes.append(
113+
contentsOf: acceptedTypes.mimeTypes.compactMap({
114+
UTType.init(mimeType: $0)
115+
}))
116+
if !allowedTypes.isEmpty {
117+
panel.allowedContentTypes = allowedTypes
129118
}
130119
}
131120

‎packages/file_selector/file_selector_macos/pubspec.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: file_selector_macos
22
description: macOS implementation of the file_selector plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_macos
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
5-
version: 0.9.5+1
5+
version: 0.9.5+2
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)