From 6a347cb106182d68329cd32827938e26bc7e7b00 Mon Sep 17 00:00:00 2001 From: Rafal Wachol Date: Thu, 17 Oct 2024 05:34:13 +0900 Subject: [PATCH] feat(device_info_plus): Add Swift Package Manager support (#3167) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com> Co-authored-by: Volodymyr --- .../device_info_plus/.gitignore | 3 +++ .../device_info_plus/ios/Assets/.gitkeep | 0 .../ios/device_info_plus.podspec | 6 ++--- .../ios/device_info_plus/Package.swift | 27 +++++++++++++++++++ .../FPPDeviceInfoPlusPlugin.m | 2 +- .../device_info_plus}/PrivacyInfo.xcprivacy | 0 .../FPPDeviceInfoPlusPlugin.h | 0 .../macos/device_info_plus.podspec | 4 +-- .../macos/device_info_plus/Package.swift | 23 ++++++++++++++++ .../Sources/device_info_plus}/CwlSysctl.swift | 0 .../DeviceInfoPlusMacosPlugin.swift | 0 .../device_info_plus}/PrivacyInfo.xcprivacy | 0 .../device_info_plus}/SystemUUID.swift | 0 13 files changed, 59 insertions(+), 6 deletions(-) delete mode 100644 packages/device_info_plus/device_info_plus/ios/Assets/.gitkeep create mode 100644 packages/device_info_plus/device_info_plus/ios/device_info_plus/Package.swift rename packages/device_info_plus/device_info_plus/ios/{Classes => device_info_plus/Sources/device_info_plus}/FPPDeviceInfoPlusPlugin.m (97%) rename packages/device_info_plus/device_info_plus/ios/{ => device_info_plus/Sources/device_info_plus}/PrivacyInfo.xcprivacy (100%) rename packages/device_info_plus/device_info_plus/ios/{Classes => device_info_plus/Sources/device_info_plus/include/device_info_plus}/FPPDeviceInfoPlusPlugin.h (100%) create mode 100644 packages/device_info_plus/device_info_plus/macos/device_info_plus/Package.swift rename packages/device_info_plus/device_info_plus/macos/{Classes => device_info_plus/Sources/device_info_plus}/CwlSysctl.swift (100%) rename packages/device_info_plus/device_info_plus/macos/{Classes => device_info_plus/Sources/device_info_plus}/DeviceInfoPlusMacosPlugin.swift (100%) rename packages/device_info_plus/device_info_plus/macos/{ => device_info_plus/Sources/device_info_plus}/PrivacyInfo.xcprivacy (100%) rename packages/device_info_plus/device_info_plus/macos/{Classes => device_info_plus/Sources/device_info_plus}/SystemUUID.swift (100%) diff --git a/packages/device_info_plus/device_info_plus/.gitignore b/packages/device_info_plus/device_info_plus/.gitignore index 88ce490e47..ece9169b44 100644 --- a/packages/device_info_plus/device_info_plus/.gitignore +++ b/packages/device_info_plus/device_info_plus/.gitignore @@ -11,9 +11,11 @@ flutter_export_environment.sh examples/all_plugins/pubspec.yaml +.build/ Podfile Podfile.lock Pods/ +.swiftpm/ .symlinks/ **/Flutter/App.framework/ **/Flutter/ephemeral/ @@ -45,3 +47,4 @@ build/ .project .classpath .settings + diff --git a/packages/device_info_plus/device_info_plus/ios/Assets/.gitkeep b/packages/device_info_plus/device_info_plus/ios/Assets/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/device_info_plus/device_info_plus/ios/device_info_plus.podspec b/packages/device_info_plus/device_info_plus/ios/device_info_plus.podspec index 26c5a39fe7..6038dd2988 100644 --- a/packages/device_info_plus/device_info_plus/ios/device_info_plus.podspec +++ b/packages/device_info_plus/device_info_plus/ios/device_info_plus.podspec @@ -14,11 +14,11 @@ Downloaded by pub (not CocoaPods). s.author = { 'Flutter Community Team' => 'authors@fluttercommunity.dev' } s.source = { :http => 'https://github.com/fluttercommunity/plus_plugins/tree/main/packages/device_info_plus' } s.documentation_url = 'https://pub.dev/packages/device_info_plus' - s.source_files = 'Classes/**/*' - s.public_header_files = 'Classes/**/*.h' + s.source_files = 'device_info_plus/Sources/device_info_plus/**/*.{h,m}' + s.public_header_files = 'device_info_plus/Sources/device_info_plus/include/**/*.h' s.dependency 'Flutter' s.platform = :ios, '12.0' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } - s.resource_bundles = {'device_info_plus_privacy' => ['PrivacyInfo.xcprivacy']} + s.resource_bundles = {'device_info_plus_privacy' => ['device_info_plus/Sources/device_info_plus/PrivacyInfo.xcprivacy']} end diff --git a/packages/device_info_plus/device_info_plus/ios/device_info_plus/Package.swift b/packages/device_info_plus/device_info_plus/ios/device_info_plus/Package.swift new file mode 100644 index 0000000000..a4defdd79c --- /dev/null +++ b/packages/device_info_plus/device_info_plus/ios/device_info_plus/Package.swift @@ -0,0 +1,27 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "device_info_plus", + platforms: [ + .iOS("12.0"), + ], + products: [ + .library(name: "device-info-plus", targets: ["device_info_plus"]) + ], + dependencies: [], + targets: [ + .target( + name: "device_info_plus", + dependencies: [], + resources: [ + .process("PrivacyInfo.xcprivacy"), + ], + cSettings: [ + .headerSearchPath("include/device_info_plus") + ] + ) + ] +) diff --git a/packages/device_info_plus/device_info_plus/ios/Classes/FPPDeviceInfoPlusPlugin.m b/packages/device_info_plus/device_info_plus/ios/device_info_plus/Sources/device_info_plus/FPPDeviceInfoPlusPlugin.m similarity index 97% rename from packages/device_info_plus/device_info_plus/ios/Classes/FPPDeviceInfoPlusPlugin.m rename to packages/device_info_plus/device_info_plus/ios/device_info_plus/Sources/device_info_plus/FPPDeviceInfoPlusPlugin.m index dd85a0c6fe..889f4d3afd 100644 --- a/packages/device_info_plus/device_info_plus/ios/Classes/FPPDeviceInfoPlusPlugin.m +++ b/packages/device_info_plus/device_info_plus/ios/device_info_plus/Sources/device_info_plus/FPPDeviceInfoPlusPlugin.m @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "FPPDeviceInfoPlusPlugin.h" +#import "./include/device_info_plus/FPPDeviceInfoPlusPlugin.h" #import @implementation FPPDeviceInfoPlusPlugin diff --git a/packages/device_info_plus/device_info_plus/ios/PrivacyInfo.xcprivacy b/packages/device_info_plus/device_info_plus/ios/device_info_plus/Sources/device_info_plus/PrivacyInfo.xcprivacy similarity index 100% rename from packages/device_info_plus/device_info_plus/ios/PrivacyInfo.xcprivacy rename to packages/device_info_plus/device_info_plus/ios/device_info_plus/Sources/device_info_plus/PrivacyInfo.xcprivacy diff --git a/packages/device_info_plus/device_info_plus/ios/Classes/FPPDeviceInfoPlusPlugin.h b/packages/device_info_plus/device_info_plus/ios/device_info_plus/Sources/device_info_plus/include/device_info_plus/FPPDeviceInfoPlusPlugin.h similarity index 100% rename from packages/device_info_plus/device_info_plus/ios/Classes/FPPDeviceInfoPlusPlugin.h rename to packages/device_info_plus/device_info_plus/ios/device_info_plus/Sources/device_info_plus/include/device_info_plus/FPPDeviceInfoPlusPlugin.h diff --git a/packages/device_info_plus/device_info_plus/macos/device_info_plus.podspec b/packages/device_info_plus/device_info_plus/macos/device_info_plus.podspec index b437ffb64c..1e0235d424 100644 --- a/packages/device_info_plus/device_info_plus/macos/device_info_plus.podspec +++ b/packages/device_info_plus/device_info_plus/macos/device_info_plus.podspec @@ -13,8 +13,8 @@ https://github.com/flutter/flutter/issues/46618 s.license = { :file => '../LICENSE' } s.author = { 'Flutter Community' => 'authors@fluttercommunity.dev' } s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.public_header_files = 'Classes/**/*.h' + s.source_files = 'device_info_plus/Sources/device_info_plus/**/*.swift' + s.public_header_files = 'device_info_plus/Sources/device_info_plus/**/*.h' s.dependency 'FlutterMacOS' s.platform = :osx diff --git a/packages/device_info_plus/device_info_plus/macos/device_info_plus/Package.swift b/packages/device_info_plus/device_info_plus/macos/device_info_plus/Package.swift new file mode 100644 index 0000000000..c7de43378f --- /dev/null +++ b/packages/device_info_plus/device_info_plus/macos/device_info_plus/Package.swift @@ -0,0 +1,23 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "device_info_plus", + platforms: [ + .macOS("10.14") + ], + products: [ + .library(name: "device-info-plus", targets: ["device_info_plus"]) + ], + dependencies: [], + targets: [ + .target( + name: "device_info_plus", + dependencies: [], + resources: [ + ] + ) + ] +) diff --git a/packages/device_info_plus/device_info_plus/macos/Classes/CwlSysctl.swift b/packages/device_info_plus/device_info_plus/macos/device_info_plus/Sources/device_info_plus/CwlSysctl.swift similarity index 100% rename from packages/device_info_plus/device_info_plus/macos/Classes/CwlSysctl.swift rename to packages/device_info_plus/device_info_plus/macos/device_info_plus/Sources/device_info_plus/CwlSysctl.swift diff --git a/packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift b/packages/device_info_plus/device_info_plus/macos/device_info_plus/Sources/device_info_plus/DeviceInfoPlusMacosPlugin.swift similarity index 100% rename from packages/device_info_plus/device_info_plus/macos/Classes/DeviceInfoPlusMacosPlugin.swift rename to packages/device_info_plus/device_info_plus/macos/device_info_plus/Sources/device_info_plus/DeviceInfoPlusMacosPlugin.swift diff --git a/packages/device_info_plus/device_info_plus/macos/PrivacyInfo.xcprivacy b/packages/device_info_plus/device_info_plus/macos/device_info_plus/Sources/device_info_plus/PrivacyInfo.xcprivacy similarity index 100% rename from packages/device_info_plus/device_info_plus/macos/PrivacyInfo.xcprivacy rename to packages/device_info_plus/device_info_plus/macos/device_info_plus/Sources/device_info_plus/PrivacyInfo.xcprivacy diff --git a/packages/device_info_plus/device_info_plus/macos/Classes/SystemUUID.swift b/packages/device_info_plus/device_info_plus/macos/device_info_plus/Sources/device_info_plus/SystemUUID.swift similarity index 100% rename from packages/device_info_plus/device_info_plus/macos/Classes/SystemUUID.swift rename to packages/device_info_plus/device_info_plus/macos/device_info_plus/Sources/device_info_plus/SystemUUID.swift