[path_provider] Fix iOS `getApplicationSupportDirectory` regression (#7026)
When switching iOS to share the macOS implementation, the application
support path for iOS accidentally changed because I forgot the macOS
implementation added an extra subdirectory to it. This fixes that
regression by returning iOS to the path `path_provider_ios` used.
Fixes https://github.com/flutter/flutter/issues/119133
diff --git a/packages/path_provider/path_provider_foundation/CHANGELOG.md b/packages/path_provider/path_provider_foundation/CHANGELOG.md
index a65177e..17e45d3 100644
--- a/packages/path_provider/path_provider_foundation/CHANGELOG.md
+++ b/packages/path_provider/path_provider_foundation/CHANGELOG.md
@@ -1,6 +1,6 @@
-## NEXT
+## 2.1.1
-* Updates minimum Flutter version to 3.0.
+* Fixes a regression in the path retured by `getApplicationSupportDirectory` on iOS.
## 2.1.0
diff --git a/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift b/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift
index 770bcb3..af04309 100644
--- a/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift
+++ b/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift
@@ -24,12 +24,19 @@
func getDirectoryPath(type: DirectoryType) -> String? {
var path = getDirectory(ofType: fileManagerDirectoryForType(type))
+ #if os(macOS)
+ // In a non-sandboxed app, this is a shared directory where applications are
+ // expected to use its bundle ID as a subdirectory. (For non-sandboxed apps,
+ // adding the extra path is harmless).
+ // This is not done for iOS, for compatibility with older versions of the
+ // plugin.
if type == .applicationSupport {
if let basePath = path {
let basePathURL = URL.init(fileURLWithPath: basePath)
path = basePathURL.appendingPathComponent(Bundle.main.bundleIdentifier!).path
}
}
+ #endif
return path
}
}
diff --git a/packages/path_provider/path_provider_foundation/darwin/Tests/RunnerTests.swift b/packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift
similarity index 80%
rename from packages/path_provider/path_provider_foundation/darwin/Tests/RunnerTests.swift
rename to packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift
index 1f3e790..99a56f2 100644
--- a/packages/path_provider/path_provider_foundation/darwin/Tests/RunnerTests.swift
+++ b/packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift
@@ -39,8 +39,19 @@
func testGetApplicationSupportDirectory() throws {
let plugin = PathProviderPlugin()
let path = plugin.getDirectoryPath(type: .applicationSupport)
- // The application support directory path should be the system application support
- // path with an added subdirectory based on the app name.
+#if os(iOS)
+ // On iOS, the application support directory path should be just the system application
+ // support path.
+ XCTAssertEqual(
+ path,
+ NSSearchPathForDirectoriesInDomains(
+ FileManager.SearchPathDirectory.applicationSupportDirectory,
+ FileManager.SearchPathDomainMask.userDomainMask,
+ true
+ ).first)
+#else
+ // On macOS, the application support directory path should be the system application
+ // support path with an added subdirectory based on the app name.
XCTAssert(
path!.hasPrefix(
NSSearchPathForDirectoriesInDomains(
@@ -49,6 +60,7 @@
true
).first!))
XCTAssert(path!.hasSuffix("Example"))
+#endif
}
func testGetLibraryDirectory() throws {
diff --git a/packages/path_provider/path_provider_foundation/example/ios/Runner.xcodeproj/project.pbxproj b/packages/path_provider/path_provider_foundation/example/ios/Runner.xcodeproj/project.pbxproj
index 866a166..70cdc76 100644
--- a/packages/path_provider/path_provider_foundation/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/packages/path_provider/path_provider_foundation/example/ios/Runner.xcodeproj/project.pbxproj
@@ -8,7 +8,7 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
- 3380327729784D96002D32AE /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3380327629784D96002D32AE /* RunnerTests.swift */; };
+ 33258D7929818305006BAA98 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33258D7729818302006BAA98 /* RunnerTests.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
569E86265D93B926F433B2DF /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 479D5DD53D431F6BBABA2E43 /* Pods_Runner.framework */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
@@ -45,8 +45,8 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
1E28C831B7D8EA9408BFB69A /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
+ 33258D7729818302006BAA98 /* RunnerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RunnerTests.swift; path = ../../darwin/RunnerTests/RunnerTests.swift; sourceTree = "<group>"; };
3380327429784D96002D32AE /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
- 3380327629784D96002D32AE /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RunnerTests.swift; path = ../../../darwin/Tests/RunnerTests.swift; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
479D5DD53D431F6BBABA2E43 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5DB8EF5A2759054360D79B8D /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
@@ -87,12 +87,12 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
- 3380327529784D96002D32AE /* RunnerTests */ = {
+ 33258D76298182CC006BAA98 /* RunnerTests */ = {
isa = PBXGroup;
children = (
- 3380327629784D96002D32AE /* RunnerTests.swift */,
+ 33258D7729818302006BAA98 /* RunnerTests.swift */,
);
- path = RunnerTests;
+ name = RunnerTests;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
@@ -111,7 +111,7 @@
children = (
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
- 3380327529784D96002D32AE /* RunnerTests */,
+ 33258D76298182CC006BAA98 /* RunnerTests */,
97C146EF1CF9000F007C117D /* Products */,
E1C876D20454FC3A1ED7F7E5 /* Pods */,
C72F144CE69E83C4574EB334 /* Frameworks */,
@@ -365,7 +365,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 3380327729784D96002D32AE /* RunnerTests.swift in Sources */,
+ 33258D7929818305006BAA98 /* RunnerTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/packages/path_provider/path_provider_foundation/example/macos/Runner.xcodeproj/project.pbxproj b/packages/path_provider/path_provider_foundation/example/macos/Runner.xcodeproj/project.pbxproj
index 54b137e..5abc18a 100644
--- a/packages/path_provider/path_provider_foundation/example/macos/Runner.xcodeproj/project.pbxproj
+++ b/packages/path_provider/path_provider_foundation/example/macos/Runner.xcodeproj/project.pbxproj
@@ -82,7 +82,7 @@
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
33EBD3A726728EA70013E557 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
- 33EBD3A926728EA70013E557 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ../../../darwin/Tests/RunnerTests.swift; sourceTree = "<group>"; };
+ 33EBD3A926728EA70013E557 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ../../../darwin/RunnerTests/RunnerTests.swift; sourceTree = "<group>"; };
33EBD3AB26728EA70013E557 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
46139048DB9F59D473B61B5E /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
diff --git a/packages/path_provider/path_provider_foundation/pubspec.yaml b/packages/path_provider/path_provider_foundation/pubspec.yaml
index a0d14c9..9ceb115 100644
--- a/packages/path_provider/path_provider_foundation/pubspec.yaml
+++ b/packages/path_provider/path_provider_foundation/pubspec.yaml
@@ -2,11 +2,11 @@
description: iOS and macOS implementation of the path_provider plugin
repository: https://github.com/flutter/plugins/tree/main/packages/path_provider/path_provider_foundation
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+path_provider%22
-version: 2.1.0
+version: 2.1.1
environment:
sdk: ">=2.12.0 <3.0.0"
- flutter: ">=3.0.0"
+ flutter: ">=2.10.0"
flutter:
plugin: