From 74262669b757f66d71989388da70674e966b1b28 Mon Sep 17 00:00:00 2001 From: "Igor K." Date: Mon, 24 Aug 2026 03:29:35 +0300 Subject: [PATCH 1/3] feat(ios): add Swift Package Manager support Co-authored-by: Cursor --- .gitignore | 4 +++ ios/.gitignore | 5 +++- ios/home_widget.podspec | 3 ++- ios/home_widget/Package.swift | 26 +++++++++++++++++++ .../HomeWidgetBackgroundWorker.swift | 0 .../Sources/home_widget}/HomeWidgetPlugin.m | 0 .../home_widget}/SwiftHomeWidgetPlugin.swift | 0 .../include/home_widget}/HomeWidgetPlugin.h | 0 8 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 ios/home_widget/Package.swift rename ios/{Classes => home_widget/Sources/home_widget}/HomeWidgetBackgroundWorker.swift (100%) rename ios/{Classes => home_widget/Sources/home_widget}/HomeWidgetPlugin.m (100%) rename ios/{Classes => home_widget/Sources/home_widget}/SwiftHomeWidgetPlugin.swift (100%) rename ios/{Classes => home_widget/Sources/home_widget/include/home_widget}/HomeWidgetPlugin.h (100%) diff --git a/.gitignore b/.gitignore index 41a386e5..cf7166f2 100644 --- a/.gitignore +++ b/.gitignore @@ -131,3 +131,7 @@ app.*.symbols # don't check in golden failure output **/failures/*.png + +# Swift Package Manager +.build/ +.swiftpm/ diff --git a/ios/.gitignore b/ios/.gitignore index aa479fd3..1041915b 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -34,4 +34,7 @@ Icon? .tags* /Flutter/Generated.xcconfig -/Flutter/flutter_export_environment.sh \ No newline at end of file +/Flutter/flutter_export_environment.sh + +.build/ +.swiftpm/ diff --git a/ios/home_widget.podspec b/ios/home_widget.podspec index 49a40c06..1f74060b 100644 --- a/ios/home_widget.podspec +++ b/ios/home_widget.podspec @@ -13,7 +13,8 @@ A new flutter plugin project. s.license = { :file => '../LICENSE' } s.author = { 'Your Company' => 'email@example.com' } s.source = { :path => '.' } - s.source_files = 'Classes/**/*' + s.source_files = 'home_widget/Sources/home_widget/**/*.{h,m,swift}' + s.public_header_files = 'home_widget/Sources/home_widget/include/home_widget/**/*.h' s.dependency 'Flutter' s.platform = :ios, '11.0' diff --git a/ios/home_widget/Package.swift b/ios/home_widget/Package.swift new file mode 100644 index 00000000..a7a7b1a7 --- /dev/null +++ b/ios/home_widget/Package.swift @@ -0,0 +1,26 @@ +// swift-tools-version: 5.9 +import PackageDescription + +let package = Package( + name: "home_widget", + platforms: [ + .iOS("13.0") + ], + products: [ + .library(name: "home-widget", targets: ["home_widget"]) + ], + dependencies: [ + .package(name: "FlutterFramework", path: "../FlutterFramework") + ], + targets: [ + .target( + name: "home_widget", + dependencies: [ + .product(name: "FlutterFramework", package: "FlutterFramework") + ], + cSettings: [ + .headerSearchPath("include/home_widget") + ] + ) + ] +) diff --git a/ios/Classes/HomeWidgetBackgroundWorker.swift b/ios/home_widget/Sources/home_widget/HomeWidgetBackgroundWorker.swift similarity index 100% rename from ios/Classes/HomeWidgetBackgroundWorker.swift rename to ios/home_widget/Sources/home_widget/HomeWidgetBackgroundWorker.swift diff --git a/ios/Classes/HomeWidgetPlugin.m b/ios/home_widget/Sources/home_widget/HomeWidgetPlugin.m similarity index 100% rename from ios/Classes/HomeWidgetPlugin.m rename to ios/home_widget/Sources/home_widget/HomeWidgetPlugin.m diff --git a/ios/Classes/SwiftHomeWidgetPlugin.swift b/ios/home_widget/Sources/home_widget/SwiftHomeWidgetPlugin.swift similarity index 100% rename from ios/Classes/SwiftHomeWidgetPlugin.swift rename to ios/home_widget/Sources/home_widget/SwiftHomeWidgetPlugin.swift diff --git a/ios/Classes/HomeWidgetPlugin.h b/ios/home_widget/Sources/home_widget/include/home_widget/HomeWidgetPlugin.h similarity index 100% rename from ios/Classes/HomeWidgetPlugin.h rename to ios/home_widget/Sources/home_widget/include/home_widget/HomeWidgetPlugin.h From 155ce8b9f2b35ed79c65c08a17176a37e374162b Mon Sep 17 00:00:00 2001 From: "Igor K." Date: Mon, 24 Aug 2026 03:48:30 +0300 Subject: [PATCH 2/3] fix(ios): split mixed-language SwiftPM targets Co-authored-by: Cursor --- ios/home_widget.podspec | 2 +- ios/home_widget/Package.swift | 7 +++++++ ios/home_widget/Sources/home_widget/HomeWidgetPlugin.m | 4 ++++ .../HomeWidgetBackgroundWorker.swift | 0 .../SwiftHomeWidgetPlugin.swift | 0 5 files changed, 12 insertions(+), 1 deletion(-) rename ios/home_widget/Sources/{home_widget => home_widget_swift}/HomeWidgetBackgroundWorker.swift (100%) rename ios/home_widget/Sources/{home_widget => home_widget_swift}/SwiftHomeWidgetPlugin.swift (100%) diff --git a/ios/home_widget.podspec b/ios/home_widget.podspec index 1f74060b..5b093785 100644 --- a/ios/home_widget.podspec +++ b/ios/home_widget.podspec @@ -13,7 +13,7 @@ A new flutter plugin project. s.license = { :file => '../LICENSE' } s.author = { 'Your Company' => 'email@example.com' } s.source = { :path => '.' } - s.source_files = 'home_widget/Sources/home_widget/**/*.{h,m,swift}' + s.source_files = 'home_widget/Sources/**/*.{h,m,swift}' s.public_header_files = 'home_widget/Sources/home_widget/include/home_widget/**/*.h' s.dependency 'Flutter' s.platform = :ios, '11.0' diff --git a/ios/home_widget/Package.swift b/ios/home_widget/Package.swift index a7a7b1a7..01b6859d 100644 --- a/ios/home_widget/Package.swift +++ b/ios/home_widget/Package.swift @@ -13,9 +13,16 @@ let package = Package( .package(name: "FlutterFramework", path: "../FlutterFramework") ], targets: [ + .target( + name: "home_widget_swift", + dependencies: [ + .product(name: "FlutterFramework", package: "FlutterFramework") + ] + ), .target( name: "home_widget", dependencies: [ + "home_widget_swift", .product(name: "FlutterFramework", package: "FlutterFramework") ], cSettings: [ diff --git a/ios/home_widget/Sources/home_widget/HomeWidgetPlugin.m b/ios/home_widget/Sources/home_widget/HomeWidgetPlugin.m index 61d15aaf..5fc2e8cf 100644 --- a/ios/home_widget/Sources/home_widget/HomeWidgetPlugin.m +++ b/ios/home_widget/Sources/home_widget/HomeWidgetPlugin.m @@ -1,4 +1,7 @@ #import "HomeWidgetPlugin.h" +#if SWIFT_PACKAGE +@import home_widget_swift; +#else #if __has_include() #import #else @@ -7,6 +10,7 @@ // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 #import "home_widget-Swift.h" #endif +#endif @implementation HomeWidgetPlugin + (void)registerWithRegistrar:(NSObject*)registrar { diff --git a/ios/home_widget/Sources/home_widget/HomeWidgetBackgroundWorker.swift b/ios/home_widget/Sources/home_widget_swift/HomeWidgetBackgroundWorker.swift similarity index 100% rename from ios/home_widget/Sources/home_widget/HomeWidgetBackgroundWorker.swift rename to ios/home_widget/Sources/home_widget_swift/HomeWidgetBackgroundWorker.swift diff --git a/ios/home_widget/Sources/home_widget/SwiftHomeWidgetPlugin.swift b/ios/home_widget/Sources/home_widget_swift/SwiftHomeWidgetPlugin.swift similarity index 100% rename from ios/home_widget/Sources/home_widget/SwiftHomeWidgetPlugin.swift rename to ios/home_widget/Sources/home_widget_swift/SwiftHomeWidgetPlugin.swift From 7cccba231a5b16e2110f9f8aea9c66a8aae8bdbc Mon Sep 17 00:00:00 2001 From: "Igor K." Date: Mon, 24 Aug 2026 03:58:34 +0300 Subject: [PATCH 3/3] fix(ios): register Swift plugin from background worker The ObjC HomeWidgetPlugin shim is a separate SPM target, so the Swift worker must call SwiftHomeWidgetPlugin.register directly. Co-authored-by: Cursor --- .../Sources/home_widget_swift/HomeWidgetBackgroundWorker.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/home_widget/Sources/home_widget_swift/HomeWidgetBackgroundWorker.swift b/ios/home_widget/Sources/home_widget_swift/HomeWidgetBackgroundWorker.swift index 0696685a..7404b1f0 100644 --- a/ios/home_widget/Sources/home_widget_swift/HomeWidgetBackgroundWorker.swift +++ b/ios/home_widget/Sources/home_widget_swift/HomeWidgetBackgroundWorker.swift @@ -59,7 +59,7 @@ public struct HomeWidgetBackgroundWorker { if registerPlugins != nil { registerPlugins?(engine!) } else { - HomeWidgetPlugin.register(with: engine!.registrar(forPlugin: "home_widget")!) + SwiftHomeWidgetPlugin.register(with: engine!.registrar(forPlugin: "home_widget")!) } channel?.setMethodCallHandler(handle)