From 9ba32e49755f2632bf638d6f381bdcea47f7c60c Mon Sep 17 00:00:00 2001 From: Koji Wakamiya Date: Sat, 10 Aug 2024 11:38:18 +0900 Subject: [PATCH] feat(battery_plus): Support Swift Package Manager --- .gitignore | 2 ++ .../battery_plus/ios/battery_plus.podspec | 6 ++--- .../ios/battery_plus/Package.swift | 27 +++++++++++++++++++ .../battery_plus}/FPPBatteryPlusPlugin.m | 2 +- .../battery_plus}/PrivacyInfo.xcprivacy | 0 .../include/battery_plus}/.gitkeep | 0 .../battery_plus}/FPPBatteryPlusPlugin.h | 0 .../battery_plus/macos/battery_plus.podspec | 2 +- .../macos/battery_plus/Package.swift | 22 +++++++++++++++ .../BatteryPlusChargingHandler.swift | 0 .../BatteryPlusMacosPlugin.swift | 0 11 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 packages/battery_plus/battery_plus/ios/battery_plus/Package.swift rename packages/battery_plus/battery_plus/ios/{Classes => battery_plus/Sources/battery_plus}/FPPBatteryPlusPlugin.m (98%) rename packages/battery_plus/battery_plus/ios/{ => battery_plus/Sources/battery_plus}/PrivacyInfo.xcprivacy (100%) rename packages/battery_plus/battery_plus/ios/{Assets => battery_plus/Sources/battery_plus/include/battery_plus}/.gitkeep (100%) rename packages/battery_plus/battery_plus/ios/{Classes => battery_plus/Sources/battery_plus/include/battery_plus}/FPPBatteryPlusPlugin.h (100%) create mode 100644 packages/battery_plus/battery_plus/macos/battery_plus/Package.swift rename packages/battery_plus/battery_plus/macos/{Classes => battery_plus/Sources/battery_plus}/BatteryPlusChargingHandler.swift (100%) rename packages/battery_plus/battery_plus/macos/{Classes => battery_plus/Sources/battery_plus}/BatteryPlusMacosPlugin.swift (100%) diff --git a/.gitignore b/.gitignore index 57b8e9671c4..2d6710764ec 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,11 @@ flutter_export_environment.sh examples/all_plugins/pubspec.yaml +.build/ Podfile Podfile.lock Pods/ +.swiftpm/ .symlinks/ **/Flutter/App.framework/ **/Flutter/ephemeral/ diff --git a/packages/battery_plus/battery_plus/ios/battery_plus.podspec b/packages/battery_plus/battery_plus/ios/battery_plus.podspec index 39c05510b84..7bdf228df75 100644 --- a/packages/battery_plus/battery_plus/ios/battery_plus.podspec +++ b/packages/battery_plus/battery_plus/ios/battery_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/battery_plus' } s.documentation_url = 'https://pub.dev/packages/battery_plus' - s.source_files = 'Classes/**/*' - s.public_header_files = 'Classes/**/*.h' + s.source_files = 'battery_plus/Sources/battery_plus/**/*.{h,m}' + s.public_header_files = 'battery_plus/Sources/battery_plus/include/**/*.h' s.dependency 'Flutter' s.platform = :ios, '12.0' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } - s.resource_bundles = {'batery_plus_privacy' => ['PrivacyInfo.xcprivacy']} + s.resource_bundles = {'batery_plus_privacy' => ['battery_plus/Sources/battery_plus/PrivacyInfo.xcprivacy']} end diff --git a/packages/battery_plus/battery_plus/ios/battery_plus/Package.swift b/packages/battery_plus/battery_plus/ios/battery_plus/Package.swift new file mode 100644 index 00000000000..59d98989b2a --- /dev/null +++ b/packages/battery_plus/battery_plus/ios/battery_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: "battery_plus", + platforms: [ + .iOS("12.0") + ], + products: [ + .library(name: "battery-plus", targets: ["battery_plus"]) + ], + dependencies: [], + targets: [ + .target( + name: "battery_plus", + dependencies: [], + resources: [ + .process("PrivacyInfo.xcprivacy"), + ], + cSettings: [ + .headerSearchPath("include/battery_plus") + ] + ) + ] +) diff --git a/packages/battery_plus/battery_plus/ios/Classes/FPPBatteryPlusPlugin.m b/packages/battery_plus/battery_plus/ios/battery_plus/Sources/battery_plus/FPPBatteryPlusPlugin.m similarity index 98% rename from packages/battery_plus/battery_plus/ios/Classes/FPPBatteryPlusPlugin.m rename to packages/battery_plus/battery_plus/ios/battery_plus/Sources/battery_plus/FPPBatteryPlusPlugin.m index 3f755e4bb03..81e95d01bb9 100644 --- a/packages/battery_plus/battery_plus/ios/Classes/FPPBatteryPlusPlugin.m +++ b/packages/battery_plus/battery_plus/ios/battery_plus/Sources/battery_plus/FPPBatteryPlusPlugin.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 "FPPBatteryPlusPlugin.h" +#import "./include/battery_plus/FPPBatteryPlusPlugin.h" @interface FPPBatteryPlusPlugin () @end diff --git a/packages/battery_plus/battery_plus/ios/PrivacyInfo.xcprivacy b/packages/battery_plus/battery_plus/ios/battery_plus/Sources/battery_plus/PrivacyInfo.xcprivacy similarity index 100% rename from packages/battery_plus/battery_plus/ios/PrivacyInfo.xcprivacy rename to packages/battery_plus/battery_plus/ios/battery_plus/Sources/battery_plus/PrivacyInfo.xcprivacy diff --git a/packages/battery_plus/battery_plus/ios/Assets/.gitkeep b/packages/battery_plus/battery_plus/ios/battery_plus/Sources/battery_plus/include/battery_plus/.gitkeep similarity index 100% rename from packages/battery_plus/battery_plus/ios/Assets/.gitkeep rename to packages/battery_plus/battery_plus/ios/battery_plus/Sources/battery_plus/include/battery_plus/.gitkeep diff --git a/packages/battery_plus/battery_plus/ios/Classes/FPPBatteryPlusPlugin.h b/packages/battery_plus/battery_plus/ios/battery_plus/Sources/battery_plus/include/battery_plus/FPPBatteryPlusPlugin.h similarity index 100% rename from packages/battery_plus/battery_plus/ios/Classes/FPPBatteryPlusPlugin.h rename to packages/battery_plus/battery_plus/ios/battery_plus/Sources/battery_plus/include/battery_plus/FPPBatteryPlusPlugin.h diff --git a/packages/battery_plus/battery_plus/macos/battery_plus.podspec b/packages/battery_plus/battery_plus/macos/battery_plus.podspec index 7f715df700f..b5b13d269eb 100644 --- a/packages/battery_plus/battery_plus/macos/battery_plus.podspec +++ b/packages/battery_plus/battery_plus/macos/battery_plus.podspec @@ -13,7 +13,7 @@ A Flutter plugin for accessing information about the battery state(full, chargin s.license = { :file => '../LICENSE' } s.author = { 'Flutter Community' => 'authors@fluttercommunity.dev' } s.source = { :path => 'https://github.com/fluttercommunity/plus_plugins/tree/main/packages/battery_plus' } - s.source_files = 'Classes/**/*' + s.source_files = 'battery_plus/Sources/battery_plus/**/*.swift' s.dependency 'FlutterMacOS' s.platform = :osx, '10.14' diff --git a/packages/battery_plus/battery_plus/macos/battery_plus/Package.swift b/packages/battery_plus/battery_plus/macos/battery_plus/Package.swift new file mode 100644 index 00000000000..d9b17f078a8 --- /dev/null +++ b/packages/battery_plus/battery_plus/macos/battery_plus/Package.swift @@ -0,0 +1,22 @@ +// 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: "battery_plus", + platforms: [ + .macOS("10.14") + ], + products: [ + .library(name: "battery-plus", targets: ["battery_plus"]) + ], + dependencies: [], + targets: [ + .target( + name: "battery_plus", + dependencies: [], + resources: [] + ) + ] +) \ No newline at end of file diff --git a/packages/battery_plus/battery_plus/macos/Classes/BatteryPlusChargingHandler.swift b/packages/battery_plus/battery_plus/macos/battery_plus/Sources/battery_plus/BatteryPlusChargingHandler.swift similarity index 100% rename from packages/battery_plus/battery_plus/macos/Classes/BatteryPlusChargingHandler.swift rename to packages/battery_plus/battery_plus/macos/battery_plus/Sources/battery_plus/BatteryPlusChargingHandler.swift diff --git a/packages/battery_plus/battery_plus/macos/Classes/BatteryPlusMacosPlugin.swift b/packages/battery_plus/battery_plus/macos/battery_plus/Sources/battery_plus/BatteryPlusMacosPlugin.swift similarity index 100% rename from packages/battery_plus/battery_plus/macos/Classes/BatteryPlusMacosPlugin.swift rename to packages/battery_plus/battery_plus/macos/battery_plus/Sources/battery_plus/BatteryPlusMacosPlugin.swift