From cf65d62fa530c164e02b07944eb1d3434f20f091 Mon Sep 17 00:00:00 2001 From: charafau Date: Mon, 12 Aug 2024 17:05:42 +0900 Subject: [PATCH 1/6] add spm support for connectivity --- .../connectivity_plus/darwin/Assets/.gitkeep | 0 .../darwin/connectivity_plus.podspec | 10 ++----- .../ConnectivityPlusPlugin.m | 2 +- .../ConnectivityProvider.swift | 0 .../PathMonitorConnectivityProvider.swift | 0 .../connectivity_plus}/PrivacyInfo.xcprivacy | 0 .../SwiftConnectivityPlusPlugin.swift | 0 .../ConnectivityPlusPlugin.h | 0 .../connectivity_plus/connectivity_plus | 28 +++++++++++++++++++ 9 files changed, 32 insertions(+), 8 deletions(-) delete mode 100644 packages/connectivity_plus/connectivity_plus/darwin/Assets/.gitkeep rename packages/connectivity_plus/connectivity_plus/darwin/{Classes => connectivity_plus/Sources/connectivity_plus}/ConnectivityPlusPlugin.m (90%) rename packages/connectivity_plus/connectivity_plus/darwin/{Classes => connectivity_plus/Sources/connectivity_plus}/ConnectivityProvider.swift (100%) rename packages/connectivity_plus/connectivity_plus/darwin/{Classes => connectivity_plus/Sources/connectivity_plus}/PathMonitorConnectivityProvider.swift (100%) rename packages/connectivity_plus/connectivity_plus/darwin/{ => connectivity_plus/Sources/connectivity_plus}/PrivacyInfo.xcprivacy (100%) rename packages/connectivity_plus/connectivity_plus/darwin/{Classes => connectivity_plus/Sources/connectivity_plus}/SwiftConnectivityPlusPlugin.swift (100%) rename packages/connectivity_plus/connectivity_plus/darwin/{Classes => connectivity_plus/Sources/connectivity_plus/include/connectivity_plus}/ConnectivityPlusPlugin.h (100%) create mode 100644 packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/connectivity_plus diff --git a/packages/connectivity_plus/connectivity_plus/darwin/Assets/.gitkeep b/packages/connectivity_plus/connectivity_plus/darwin/Assets/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus.podspec b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus.podspec index faa34ac902..46258f83d8 100644 --- a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus.podspec +++ b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus.podspec @@ -14,17 +14,13 @@ 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/connectivity_plus' } s.documentation_url = 'https://pub.dev/packages/connectivity_plus' - s.source_files = [ - 'Classes/**/*' - ] - s.public_header_files = [ - 'Classes/**/*.h' - ] + s.source_files = 'connectivity_plus/Sources/connectivity_plus/**/*.{h,m,swift}' + s.public_header_files = 'connectivity_plus/Sources/connectivity_plus/include/**/*.h' s.ios.dependency 'Flutter' s.osx.dependency 'FlutterMacOS' s.ios.deployment_target = '12.0' s.osx.deployment_target = '10.14' s.swift_version = '5.0' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } - s.ios.resource_bundles = {'connectivity_plus_privacy' => ['PrivacyInfo.xcprivacy']} + s.ios.resource_bundles = {'connectivity_plus_privacy' => ['connectivity_plus/Sources/connectivity_plus/PrivacyInfo.xcprivacy']} end diff --git a/packages/connectivity_plus/connectivity_plus/darwin/Classes/ConnectivityPlusPlugin.m b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.m similarity index 90% rename from packages/connectivity_plus/connectivity_plus/darwin/Classes/ConnectivityPlusPlugin.m rename to packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.m index 43af3800bc..50986fb076 100644 --- a/packages/connectivity_plus/connectivity_plus/darwin/Classes/ConnectivityPlusPlugin.m +++ b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.m @@ -1,4 +1,4 @@ -#import "ConnectivityPlusPlugin.h" +#import "./include/connectivity_plus/ConnectivityPlusPlugin.h" #if __has_include() #import #else diff --git a/packages/connectivity_plus/connectivity_plus/darwin/Classes/ConnectivityProvider.swift b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityProvider.swift similarity index 100% rename from packages/connectivity_plus/connectivity_plus/darwin/Classes/ConnectivityProvider.swift rename to packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityProvider.swift diff --git a/packages/connectivity_plus/connectivity_plus/darwin/Classes/PathMonitorConnectivityProvider.swift b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/PathMonitorConnectivityProvider.swift similarity index 100% rename from packages/connectivity_plus/connectivity_plus/darwin/Classes/PathMonitorConnectivityProvider.swift rename to packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/PathMonitorConnectivityProvider.swift diff --git a/packages/connectivity_plus/connectivity_plus/darwin/PrivacyInfo.xcprivacy b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/PrivacyInfo.xcprivacy similarity index 100% rename from packages/connectivity_plus/connectivity_plus/darwin/PrivacyInfo.xcprivacy rename to packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/PrivacyInfo.xcprivacy diff --git a/packages/connectivity_plus/connectivity_plus/darwin/Classes/SwiftConnectivityPlusPlugin.swift b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/SwiftConnectivityPlusPlugin.swift similarity index 100% rename from packages/connectivity_plus/connectivity_plus/darwin/Classes/SwiftConnectivityPlusPlugin.swift rename to packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/SwiftConnectivityPlusPlugin.swift diff --git a/packages/connectivity_plus/connectivity_plus/darwin/Classes/ConnectivityPlusPlugin.h b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/include/connectivity_plus/ConnectivityPlusPlugin.h similarity index 100% rename from packages/connectivity_plus/connectivity_plus/darwin/Classes/ConnectivityPlusPlugin.h rename to packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/include/connectivity_plus/ConnectivityPlusPlugin.h diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/connectivity_plus b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/connectivity_plus new file mode 100644 index 0000000000..276a43a733 --- /dev/null +++ b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/connectivity_plus @@ -0,0 +1,28 @@ +// 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: "connectivity_plus", + platforms: [ + .iOS("12.0"), + .macOS("10.14") + ], + products: [ + .library(name: "connectivity-plus", targets: ["connectivity_plus"]) + ], + dependencies: [], + targets: [ + .target( + name: "connectivity_plus", + dependencies: [], + resources: [ + .process("PrivacyInfo.xcprivacy"), + ], + cSettings: [ + .headerSearchPath("include/connectivity_plus") + ] + ) + ] +) From 566b392e957b784de4bb8057d9e92ad5eae52251 Mon Sep 17 00:00:00 2001 From: charafau Date: Mon, 12 Aug 2024 17:06:44 +0900 Subject: [PATCH 2/6] rename file to package.swift --- .../darwin/connectivity_plus/{connectivity_plus => Package.swift} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/{connectivity_plus => Package.swift} (100%) diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/connectivity_plus b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Package.swift similarity index 100% rename from packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/connectivity_plus rename to packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Package.swift From f7a055d7495ffb912901e7573eb1efa41470891b Mon Sep 17 00:00:00 2001 From: charafau Date: Mon, 12 Aug 2024 17:22:58 +0900 Subject: [PATCH 3/6] remove objc files, add spm support --- .../darwin/connectivity_plus.podspec | 3 +-- .../darwin/connectivity_plus/Package.swift | 3 --- .../ConnectivityPlusPlugin.m | 15 ------------- ...gin.swift => ConnectivityPlusPlugin.swift} | 2 +- .../ConnectivityProvider.swift | 21 ------------------- .../ConnectivityPlusPlugin.h | 8 ------- 6 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.m rename packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/{SwiftConnectivityPlusPlugin.swift => ConnectivityPlusPlugin.swift} (96%) delete mode 100644 packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityProvider.swift delete mode 100644 packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/include/connectivity_plus/ConnectivityPlusPlugin.h diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus.podspec b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus.podspec index 46258f83d8..ce086c0d53 100644 --- a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus.podspec +++ b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus.podspec @@ -14,8 +14,7 @@ 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/connectivity_plus' } s.documentation_url = 'https://pub.dev/packages/connectivity_plus' - s.source_files = 'connectivity_plus/Sources/connectivity_plus/**/*.{h,m,swift}' - s.public_header_files = 'connectivity_plus/Sources/connectivity_plus/include/**/*.h' + s.source_files = 'connectivity_plus/Sources/connectivity_plus/**/*.swift' s.ios.dependency 'Flutter' s.osx.dependency 'FlutterMacOS' s.ios.deployment_target = '12.0' diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Package.swift b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Package.swift index 276a43a733..c8e80e4d21 100644 --- a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Package.swift +++ b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Package.swift @@ -19,9 +19,6 @@ let package = Package( dependencies: [], resources: [ .process("PrivacyInfo.xcprivacy"), - ], - cSettings: [ - .headerSearchPath("include/connectivity_plus") ] ) ] diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.m b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.m deleted file mode 100644 index 50986fb076..0000000000 --- a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "./include/connectivity_plus/ConnectivityPlusPlugin.h" -#if __has_include() -#import -#else -// Support project import fallback if the generated compatibility header -// is not copied when this plugin is created as a library. -// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 -#import "connectivity_plus-Swift.h" -#endif - -@implementation ConnectivityPlusPlugin -+ (void)registerWithRegistrar:(NSObject *)registrar { - [SwiftConnectivityPlusPlugin registerWithRegistrar:registrar]; -} -@end diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/SwiftConnectivityPlusPlugin.swift b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.swift similarity index 96% rename from packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/SwiftConnectivityPlusPlugin.swift rename to packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.swift index de4ac25141..0a3337fb65 100644 --- a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/SwiftConnectivityPlusPlugin.swift +++ b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.swift @@ -9,7 +9,7 @@ import Cocoa import FlutterMacOS #endif -public class SwiftConnectivityPlusPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { +public class ConnectivityPlusPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { private let connectivityProvider: ConnectivityProvider private var eventSink: FlutterEventSink? diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityProvider.swift b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityProvider.swift deleted file mode 100644 index ad2cbc1e16..0000000000 --- a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityProvider.swift +++ /dev/null @@ -1,21 +0,0 @@ -import Foundation - -public enum ConnectivityType { - case none - case wiredEthernet - case wifi - case cellular - case other -} - -public protocol ConnectivityProvider: NSObjectProtocol { - typealias ConnectivityUpdateHandler = ([ConnectivityType]) -> Void - - var currentConnectivityTypes: [ConnectivityType] { get } - - var connectivityUpdateHandler: ConnectivityUpdateHandler? { get set } - - func start() - - func stop() -} diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/include/connectivity_plus/ConnectivityPlusPlugin.h b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/include/connectivity_plus/ConnectivityPlusPlugin.h deleted file mode 100644 index dc6d193c7e..0000000000 --- a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/include/connectivity_plus/ConnectivityPlusPlugin.h +++ /dev/null @@ -1,8 +0,0 @@ -#if TARGET_OS_IOS -#import -#elif TARGET_OS_OSX -#import -#endif - -@interface ConnectivityPlusPlugin : NSObject -@end From 631faca6118fcdc71e570f6bb08c37cb2d250e9d Mon Sep 17 00:00:00 2001 From: charafau Date: Mon, 12 Aug 2024 17:28:16 +0900 Subject: [PATCH 4/6] reverted deleted file --- .../ConnectivityProvider.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityProvider.swift diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityProvider.swift b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityProvider.swift new file mode 100644 index 0000000000..ad2cbc1e16 --- /dev/null +++ b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityProvider.swift @@ -0,0 +1,21 @@ +import Foundation + +public enum ConnectivityType { + case none + case wiredEthernet + case wifi + case cellular + case other +} + +public protocol ConnectivityProvider: NSObjectProtocol { + typealias ConnectivityUpdateHandler = ([ConnectivityType]) -> Void + + var currentConnectivityTypes: [ConnectivityType] { get } + + var connectivityUpdateHandler: ConnectivityUpdateHandler? { get set } + + func start() + + func stop() +} From 92a88fb8e053ba622b5421f2f1475d98b7310dfb Mon Sep 17 00:00:00 2001 From: charafau Date: Mon, 12 Aug 2024 18:36:49 +0900 Subject: [PATCH 5/6] fix plugin swift code, change example pub spec to use library from repo --- .../Sources/connectivity_plus/ConnectivityPlusPlugin.swift | 2 +- .../connectivity_plus/example/pubspec.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.swift b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.swift index 0a3337fb65..bb62d9f29d 100644 --- a/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.swift +++ b/packages/connectivity_plus/connectivity_plus/darwin/connectivity_plus/Sources/connectivity_plus/ConnectivityPlusPlugin.swift @@ -35,7 +35,7 @@ public class ConnectivityPlusPlugin: NSObject, FlutterPlugin, FlutterStreamHandl binaryMessenger: binaryMessenger) let connectivityProvider = PathMonitorConnectivityProvider() - let instance = SwiftConnectivityPlusPlugin(connectivityProvider: connectivityProvider) + let instance = ConnectivityPlusPlugin(connectivityProvider: connectivityProvider) streamChannel.setStreamHandler(instance) registrar.addMethodCallDelegate(instance, channel: channel) diff --git a/packages/connectivity_plus/connectivity_plus/example/pubspec.yaml b/packages/connectivity_plus/connectivity_plus/example/pubspec.yaml index 64fc0b64a6..26470bb44d 100644 --- a/packages/connectivity_plus/connectivity_plus/example/pubspec.yaml +++ b/packages/connectivity_plus/connectivity_plus/example/pubspec.yaml @@ -2,13 +2,13 @@ name: connectivity_plus_example description: Demonstrates how to use the connectivity_plus plugin. environment: - sdk: '>=2.12.0 <4.0.0' + sdk: ">=2.12.0 <4.0.0" dependencies: flutter: sdk: flutter - connectivity_plus: ^6.0.5 - + connectivity_plus: + path: .. dev_dependencies: flutter_driver: sdk: flutter From 1479d11fcc9dbde63d0fd6c15dff621e56c67eb2 Mon Sep 17 00:00:00 2001 From: charafau Date: Mon, 12 Aug 2024 23:45:37 +0900 Subject: [PATCH 6/6] reverted changes in pubspec --- .../connectivity_plus/example/pubspec.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/connectivity_plus/connectivity_plus/example/pubspec.yaml b/packages/connectivity_plus/connectivity_plus/example/pubspec.yaml index 26470bb44d..64fc0b64a6 100644 --- a/packages/connectivity_plus/connectivity_plus/example/pubspec.yaml +++ b/packages/connectivity_plus/connectivity_plus/example/pubspec.yaml @@ -2,13 +2,13 @@ name: connectivity_plus_example description: Demonstrates how to use the connectivity_plus plugin. environment: - sdk: ">=2.12.0 <4.0.0" + sdk: '>=2.12.0 <4.0.0' dependencies: flutter: sdk: flutter - connectivity_plus: - path: .. + connectivity_plus: ^6.0.5 + dev_dependencies: flutter_driver: sdk: flutter