From 3fe9e8d888779b5a3dd63c3afbbca16c0c8b8606 Mon Sep 17 00:00:00 2001 From: Pedro Paulo de Amorim Date: Fri, 17 Apr 2026 21:16:58 +0100 Subject: [PATCH 1/2] feat(ios): add Swift Package Manager support Flutter is migrating to Swift Package Manager (SPM) as the default dependency manager for iOS. This adds SPM support while keeping CocoaPods compatibility, following the official migration guide. - Create ios/flutter_foreground_task/ SPM package with Package.swift - Move source files from ios/Classes/ to SPM-compliant directory layout - Update podspec source_files to point to the new paths - Add .build/ and .swiftpm/ to .gitignore Closes #379 --- .gitignore | 2 ++ ios/flutter_foreground_task.podspec | 2 +- ios/flutter_foreground_task/Package.swift | 22 +++++++++++++++++++ ...utterForegroundTaskLifecycleListener.swift | 0 .../FlutterForegroundTaskPlugin.h | 0 .../FlutterForegroundTaskPlugin.m | 0 .../FlutterForegroundTaskStarter.swift | 0 .../PreferencesKey.swift | 0 .../SceneLifecycleBridge.swift | 0 .../SwiftFlutterForegroundTaskPlugin.swift | 0 .../errors/ServiceError.swift | 0 .../models/BackgroundServiceAction.swift | 0 .../models/BackgroundServiceStatus.swift | 0 .../models/ForegroundTaskData.swift | 0 .../models/ForegroundTaskEventAction.swift | 0 .../models/ForegroundTaskEventType.swift | 0 .../models/ForegroundTaskOptions.swift | 0 .../models/NotificationButton.swift | 0 .../models/NotificationContent.swift | 0 .../models/NotificationOptions.swift | 0 .../models/NotificationPermission.swift | 0 .../service/BackgroundService.swift | 0 .../service/BackgroundServiceManager.swift | 0 .../ContinuedProcessingTaskManager.swift | 0 .../service/ForegroundTask.swift | 0 .../ForegroundTaskLifecycleListeners.swift | 0 .../NotificationPermissionManager.swift | 0 .../storage/ForegroundTaskStorage.swift | 0 28 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 ios/flutter_foreground_task/Package.swift rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/FlutterForegroundTaskLifecycleListener.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/FlutterForegroundTaskPlugin.h (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/FlutterForegroundTaskPlugin.m (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/FlutterForegroundTaskStarter.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/PreferencesKey.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/SceneLifecycleBridge.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/SwiftFlutterForegroundTaskPlugin.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/errors/ServiceError.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/models/BackgroundServiceAction.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/models/BackgroundServiceStatus.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/models/ForegroundTaskData.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/models/ForegroundTaskEventAction.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/models/ForegroundTaskEventType.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/models/ForegroundTaskOptions.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/models/NotificationButton.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/models/NotificationContent.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/models/NotificationOptions.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/models/NotificationPermission.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/service/BackgroundService.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/service/BackgroundServiceManager.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/service/ContinuedProcessingTaskManager.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/service/ForegroundTask.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/service/ForegroundTaskLifecycleListeners.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/service/NotificationPermissionManager.swift (100%) rename ios/{Classes => flutter_foreground_task/Sources/flutter_foreground_task}/storage/ForegroundTaskStorage.swift (100%) diff --git a/.gitignore b/.gitignore index ddde1066..53d6706e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ /pubspec.lock build/ +.build/ +.swiftpm/ diff --git a/ios/flutter_foreground_task.podspec b/ios/flutter_foreground_task.podspec index 45788fda..a7d68f1e 100644 --- a/ios/flutter_foreground_task.podspec +++ b/ios/flutter_foreground_task.podspec @@ -13,7 +13,7 @@ A new Flutter plugin. s.license = { :file => '../LICENSE' } s.author = { 'Your Company' => 'email@example.com' } s.source = { :path => '.' } - s.source_files = 'Classes/**/*' + s.source_files = 'flutter_foreground_task/Sources/flutter_foreground_task/**/*' s.dependency 'Flutter' s.platform = :ios, '8.0' diff --git a/ios/flutter_foreground_task/Package.swift b/ios/flutter_foreground_task/Package.swift new file mode 100644 index 00000000..770372cf --- /dev/null +++ b/ios/flutter_foreground_task/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: "flutter_foreground_task", + platforms: [ + .iOS("12.0") + ], + products: [ + .library(name: "flutter-foreground-task", targets: ["flutter_foreground_task"]) + ], + dependencies: [], + targets: [ + .target( + name: "flutter_foreground_task", + dependencies: [], + exclude: ["FlutterForegroundTaskPlugin.h", "FlutterForegroundTaskPlugin.m"] + ) + ] +) diff --git a/ios/Classes/FlutterForegroundTaskLifecycleListener.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/FlutterForegroundTaskLifecycleListener.swift similarity index 100% rename from ios/Classes/FlutterForegroundTaskLifecycleListener.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/FlutterForegroundTaskLifecycleListener.swift diff --git a/ios/Classes/FlutterForegroundTaskPlugin.h b/ios/flutter_foreground_task/Sources/flutter_foreground_task/FlutterForegroundTaskPlugin.h similarity index 100% rename from ios/Classes/FlutterForegroundTaskPlugin.h rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/FlutterForegroundTaskPlugin.h diff --git a/ios/Classes/FlutterForegroundTaskPlugin.m b/ios/flutter_foreground_task/Sources/flutter_foreground_task/FlutterForegroundTaskPlugin.m similarity index 100% rename from ios/Classes/FlutterForegroundTaskPlugin.m rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/FlutterForegroundTaskPlugin.m diff --git a/ios/Classes/FlutterForegroundTaskStarter.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/FlutterForegroundTaskStarter.swift similarity index 100% rename from ios/Classes/FlutterForegroundTaskStarter.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/FlutterForegroundTaskStarter.swift diff --git a/ios/Classes/PreferencesKey.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/PreferencesKey.swift similarity index 100% rename from ios/Classes/PreferencesKey.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/PreferencesKey.swift diff --git a/ios/Classes/SceneLifecycleBridge.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/SceneLifecycleBridge.swift similarity index 100% rename from ios/Classes/SceneLifecycleBridge.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/SceneLifecycleBridge.swift diff --git a/ios/Classes/SwiftFlutterForegroundTaskPlugin.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/SwiftFlutterForegroundTaskPlugin.swift similarity index 100% rename from ios/Classes/SwiftFlutterForegroundTaskPlugin.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/SwiftFlutterForegroundTaskPlugin.swift diff --git a/ios/Classes/errors/ServiceError.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/errors/ServiceError.swift similarity index 100% rename from ios/Classes/errors/ServiceError.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/errors/ServiceError.swift diff --git a/ios/Classes/models/BackgroundServiceAction.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/models/BackgroundServiceAction.swift similarity index 100% rename from ios/Classes/models/BackgroundServiceAction.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/models/BackgroundServiceAction.swift diff --git a/ios/Classes/models/BackgroundServiceStatus.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/models/BackgroundServiceStatus.swift similarity index 100% rename from ios/Classes/models/BackgroundServiceStatus.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/models/BackgroundServiceStatus.swift diff --git a/ios/Classes/models/ForegroundTaskData.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/models/ForegroundTaskData.swift similarity index 100% rename from ios/Classes/models/ForegroundTaskData.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/models/ForegroundTaskData.swift diff --git a/ios/Classes/models/ForegroundTaskEventAction.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/models/ForegroundTaskEventAction.swift similarity index 100% rename from ios/Classes/models/ForegroundTaskEventAction.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/models/ForegroundTaskEventAction.swift diff --git a/ios/Classes/models/ForegroundTaskEventType.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/models/ForegroundTaskEventType.swift similarity index 100% rename from ios/Classes/models/ForegroundTaskEventType.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/models/ForegroundTaskEventType.swift diff --git a/ios/Classes/models/ForegroundTaskOptions.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/models/ForegroundTaskOptions.swift similarity index 100% rename from ios/Classes/models/ForegroundTaskOptions.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/models/ForegroundTaskOptions.swift diff --git a/ios/Classes/models/NotificationButton.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/models/NotificationButton.swift similarity index 100% rename from ios/Classes/models/NotificationButton.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/models/NotificationButton.swift diff --git a/ios/Classes/models/NotificationContent.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/models/NotificationContent.swift similarity index 100% rename from ios/Classes/models/NotificationContent.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/models/NotificationContent.swift diff --git a/ios/Classes/models/NotificationOptions.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/models/NotificationOptions.swift similarity index 100% rename from ios/Classes/models/NotificationOptions.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/models/NotificationOptions.swift diff --git a/ios/Classes/models/NotificationPermission.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/models/NotificationPermission.swift similarity index 100% rename from ios/Classes/models/NotificationPermission.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/models/NotificationPermission.swift diff --git a/ios/Classes/service/BackgroundService.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/service/BackgroundService.swift similarity index 100% rename from ios/Classes/service/BackgroundService.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/service/BackgroundService.swift diff --git a/ios/Classes/service/BackgroundServiceManager.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/service/BackgroundServiceManager.swift similarity index 100% rename from ios/Classes/service/BackgroundServiceManager.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/service/BackgroundServiceManager.swift diff --git a/ios/Classes/service/ContinuedProcessingTaskManager.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/service/ContinuedProcessingTaskManager.swift similarity index 100% rename from ios/Classes/service/ContinuedProcessingTaskManager.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/service/ContinuedProcessingTaskManager.swift diff --git a/ios/Classes/service/ForegroundTask.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/service/ForegroundTask.swift similarity index 100% rename from ios/Classes/service/ForegroundTask.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/service/ForegroundTask.swift diff --git a/ios/Classes/service/ForegroundTaskLifecycleListeners.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/service/ForegroundTaskLifecycleListeners.swift similarity index 100% rename from ios/Classes/service/ForegroundTaskLifecycleListeners.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/service/ForegroundTaskLifecycleListeners.swift diff --git a/ios/Classes/service/NotificationPermissionManager.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/service/NotificationPermissionManager.swift similarity index 100% rename from ios/Classes/service/NotificationPermissionManager.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/service/NotificationPermissionManager.swift diff --git a/ios/Classes/storage/ForegroundTaskStorage.swift b/ios/flutter_foreground_task/Sources/flutter_foreground_task/storage/ForegroundTaskStorage.swift similarity index 100% rename from ios/Classes/storage/ForegroundTaskStorage.swift rename to ios/flutter_foreground_task/Sources/flutter_foreground_task/storage/ForegroundTaskStorage.swift From 6da006e8a2db2eca12c7fa4220ccc55aa430c6d2 Mon Sep 17 00:00:00 2001 From: Pedro Paulo de Amorim Date: Fri, 17 Apr 2026 21:22:35 +0100 Subject: [PATCH 2/2] fix(ios): bump podspec minimum iOS version from 8.0 to 12.0 Aligns the CocoaPods deployment target with Package.swift and Flutter 3.22+'s own iOS 12.0 minimum requirement. --- ios/flutter_foreground_task.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/flutter_foreground_task.podspec b/ios/flutter_foreground_task.podspec index a7d68f1e..191bb9ed 100644 --- a/ios/flutter_foreground_task.podspec +++ b/ios/flutter_foreground_task.podspec @@ -15,7 +15,7 @@ A new Flutter plugin. s.source = { :path => '.' } s.source_files = 'flutter_foreground_task/Sources/flutter_foreground_task/**/*' s.dependency 'Flutter' - s.platform = :ios, '8.0' + s.platform = :ios, '12.0' # Flutter.framework does not contain a i386 slice. s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }