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

File tree

127 files changed

+542
-1491
lines changed

Some content is hidden

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

127 files changed

+542
-1491
lines changed

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
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.

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/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' => '[email protected]' }
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
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
**/dgph
2+
*.mode1v3
3+
*.mode2v3
4+
*.moved-aside
5+
*.pbxuser
6+
*.perspectivev3
7+
**/*sync/
8+
.sconsign.dblite
9+
.tags*
10+
**/.vagrant/
11+
**/DerivedData/
12+
Icon?
13+
**/Pods/
14+
**/.symlinks/
15+
profile
16+
xcuserdata
17+
**/.generated/
18+
Flutter/App.framework
19+
Flutter/Flutter.framework
20+
Flutter/Flutter.podspec
21+
Flutter/Generated.xcconfig
22+
Flutter/ephemeral/
23+
Flutter/app.flx
24+
Flutter/app.zip
25+
Flutter/flutter_assets/
26+
Flutter/flutter_export_environment.sh
27+
ServiceDefinitions.json
28+
Runner/GeneratedPluginRegistrant.*
29+
30+
# Exceptions to above rules.
31+
!default.mode1v3
32+
!default.mode2v3
33+
!default.pbxuser
34+
!default.perspectivev3

packages/path_provider/path_provider_ios/example/ios/Flutter/AppFrameworkInfo.plist renamed to packages/path_provider/path_provider_foundation/example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
23-
<key>UIRequiredDeviceCapabilities</key>
24-
<array>
25-
<string>arm64</string>
26-
</array>
2723
<key>MinimumOSVersion</key>
28-
<string>9.0</string>
24+
<string>11.0</string>
2925
</dict>
3026
</plist>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2+
#include "Generated.xcconfig"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2+
#include "Generated.xcconfig"

packages/path_provider/path_provider_ios/example/ios/Podfile renamed to packages/path_provider/path_provider_foundation/example/ios/Podfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '9.0'
2+
# platform :ios, '11.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
@@ -28,7 +28,11 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe
2828
flutter_ios_podfile_setup
2929

3030
target 'Runner' do
31+
use_frameworks!
32+
use_modular_headers!
33+
3134
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35+
3236
target 'RunnerTests' do
3337
inherit! :search_paths
3438
end

0 commit comments

Comments
 (0)