Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit e0c24db

Browse files
[path_provider] Merge iOS and macOS implementations (#6988)
* Rename directory; no changes * Exclude new plugin from build-all during the transition * Rename files and classes, update metadata * Make error messages non-macOS-specific * Move implementation to shared location * IGNORE IN REVIEW add symlinks * Add macOS symlink readme * Add iOS support with sharedDarwinSource * Add iOS example freshly created from template * Add iOS symlinks * Add missing library directory to example, for parity with iOS * Move unit test to shared location, and add iOS unit test target using it * Add the Swift search paths to podspec * Remove path_provider_ios * Update CODEOWNERS * Add copyrights to example files
1 parent abbcaf0 commit e0c24db

127 files changed

Lines changed: 542 additions & 1491 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CODEOWNERS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ packages/image_picker/image_picker_ios/** @vashworth
4949
packages/in_app_purchase/in_app_purchase_storekit/** @cyanglaz
5050
packages/ios_platform_images/ios/** @jmagman
5151
packages/local_auth/local_auth_ios/** @hellohuanlin
52-
packages/path_provider/path_provider_ios/** @jmagman
52+
packages/path_provider/path_provider_foundation/** @jmagman
5353
packages/quick_actions/quick_actions_ios/** @hellohuanlin
5454
packages/shared_preferences/shared_preferences_foundation/** @cyanglaz
5555
packages/url_launcher/url_launcher_ios/** @jmagman
@@ -64,7 +64,6 @@ packages/url_launcher/url_launcher_linux/** @cbracken
6464

6565
# - macOS
6666
packages/file_selector/file_selector_macos/** @cbracken
67-
packages/path_provider/path_provider_macos/** @cbracken
6867
packages/url_launcher/url_launcher_macos/** @cbracken
6968

7069
# - Windows

packages/path_provider/path_provider_macos/.gitignore renamed to packages/path_provider/path_provider_foundation/.gitignore

File renamed without changes.
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## 2.1.0
2+
3+
* Renames the package previously published as
4+
[`path_provider_macos`](https://pub.dev/packages/path_provider_macos)
5+
* Adds iOS support.
File renamed without changes.

packages/path_provider/path_provider_ios/README.md renamed to packages/path_provider/path_provider_foundation/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# path\_provider\_ios
1+
# path\_provider\_foundation
22

3-
The iOS implementation of [`path_provider`][1].
3+
The iOS and macOS implementation of [`path_provider`][1].
44

55
## Usage
66

packages/path_provider/path_provider_macos/macos/Classes/PathProviderPlugin.swift renamed to packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import FlutterMacOS
65
import Foundation
76

7+
#if os(iOS)
8+
import Flutter
9+
#elseif os(macOS)
10+
import FlutterMacOS
11+
#endif
12+
813
public class PathProviderPlugin: NSObject, FlutterPlugin, PathProviderApi {
914
public static func register(with registrar: FlutterPluginRegistrar) {
1015
let instance = PathProviderPlugin()
11-
PathProviderApiSetup.setUp(binaryMessenger: registrar.messenger, api: instance)
16+
// Workaround for https://github.com/flutter/flutter/issues/118103.
17+
#if os(iOS)
18+
let messenger = registrar.messenger()
19+
#else
20+
let messenger = registrar.messenger
21+
#endif
22+
PathProviderApiSetup.setUp(binaryMessenger: messenger, api: instance)
1223
}
1324

1425
func getDirectoryPath(type: DirectoryType) -> String? {

packages/path_provider/path_provider_macos/macos/Classes/messages.g.swift renamed to packages/path_provider/path_provider_foundation/darwin/Classes/messages.g.swift

File renamed without changes.

packages/path_provider/path_provider_macos/example/macos/RunnerTests/RunnerTests.swift renamed to packages/path_provider/path_provider_foundation/darwin/Tests/RunnerTests.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import FlutterMacOS
65
import XCTest
7-
@testable import path_provider_macos
6+
@testable import path_provider_foundation
7+
8+
#if os(iOS)
9+
import Flutter
10+
#elseif os(macOS)
11+
import FlutterMacOS
12+
#endif
813

914
class RunnerTests: XCTestCase {
1015
func testGetTemporaryDirectory() throws {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
3+
#
4+
Pod::Spec.new do |s|
5+
s.name = 'path_provider_foundation'
6+
s.version = '0.0.1'
7+
s.summary = 'An iOS and macOS implementation of the path_provider plugin.'
8+
s.description = <<-DESC
9+
An iOS and macOS implementation of the Flutter plugin for getting commonly used locations on the filesystem.
10+
DESC
11+
s.homepage = 'https://github.com/flutter/plugins/tree/main/packages/path_provider/path_provider_foundation'
12+
s.license = { :type => 'BSD', :file => '../LICENSE' }
13+
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
14+
s.source = { :http => 'https://github.com/flutter/plugins/tree/main/packages/path_provider/path_provider_foundation' }
15+
s.source_files = 'Classes/**/*'
16+
s.ios.dependency 'Flutter'
17+
s.osx.dependency 'FlutterMacOS'
18+
s.ios.deployment_target = '9.0'
19+
s.osx.deployment_target = '10.11'
20+
s.ios.xcconfig = {
21+
'LIBRARY_SEARCH_PATHS' => '$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)/ $(SDKROOT)/usr/lib/swift',
22+
'LD_RUNPATH_SEARCH_PATHS' => '/usr/lib/swift',
23+
}
24+
s.swift_version = '5.0'
25+
end

0 commit comments

Comments
 (0)