From aa9e3b69665f3c163391e5524a33ae052227c2cd Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Fri, 1 Aug 2025 07:32:55 +0100 Subject: [PATCH 1/6] chore(release): publish packages - workmanager_apple@0.9.1 - workmanager@0.9.0+1 --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ workmanager/CHANGELOG.md | 4 ++++ workmanager/pubspec.yaml | 4 ++-- workmanager_apple/CHANGELOG.md | 4 ++++ workmanager_apple/pubspec.yaml | 2 +- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65459744..7ca6dfe0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,34 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2025-08-01 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`workmanager_apple` - `v0.9.1`](#workmanager_apple---v091) + - [`workmanager` - `v0.9.0+1`](#workmanager---v0901) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `workmanager` - `v0.9.0+1` + +--- + +#### `workmanager_apple` - `v0.9.1` + + - **FEAT**: add iOS Swift Package Manager support (#631). + + ## 2025-07-31 ### Changes diff --git a/workmanager/CHANGELOG.md b/workmanager/CHANGELOG.md index e8ea30fe..4f1a85e3 100644 --- a/workmanager/CHANGELOG.md +++ b/workmanager/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.0+1 + + - Update a dependency to the latest release. + ## 0.9.0 > Note: This release has breaking changes. diff --git a/workmanager/pubspec.yaml b/workmanager/pubspec.yaml index e242544a..7bf4c914 100644 --- a/workmanager/pubspec.yaml +++ b/workmanager/pubspec.yaml @@ -1,6 +1,6 @@ name: workmanager description: Flutter Workmanager. This plugin allows you to schedule background work on Android and iOS. -version: 0.9.0 +version: 0.9.0+1 # publish_to: none homepage: https://github.com/fluttercommunity/flutter_workmanager repository: https://github.com/fluttercommunity/flutter_workmanager @@ -15,7 +15,7 @@ dependencies: sdk: flutter workmanager_platform_interface: ^0.9.0 workmanager_android: ^0.9.0 - workmanager_apple: ^0.9.0 + workmanager_apple: ^0.9.1 dev_dependencies: test: ^1.25.15 diff --git a/workmanager_apple/CHANGELOG.md b/workmanager_apple/CHANGELOG.md index e495f64c..04a2ec72 100644 --- a/workmanager_apple/CHANGELOG.md +++ b/workmanager_apple/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.1 + + - **FEAT**: add iOS Swift Package Manager support (#631). + ## 0.9.0 > Note: This release has breaking changes. diff --git a/workmanager_apple/pubspec.yaml b/workmanager_apple/pubspec.yaml index 0f433506..a3227c0f 100644 --- a/workmanager_apple/pubspec.yaml +++ b/workmanager_apple/pubspec.yaml @@ -1,6 +1,6 @@ name: workmanager_apple description: Apple platform (iOS/macOS) implementation of the workmanager plugin. -version: 0.9.0 +version: 0.9.1 # publish_to: none homepage: https://github.com/fluttercommunity/flutter_workmanager repository: https://github.com/fluttercommunity/flutter_workmanager From 7116f5f234969a662f62440590843b03c21639eb Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Tue, 5 Aug 2025 22:13:45 +0100 Subject: [PATCH 2/6] docs: fix incorrect UIBackgroundModes documentation - Remove invalid 'processing' value from UIBackgroundModes - Add clarification that BGTaskScheduler doesn't require UIBackgroundModes - Link to Apple's official UIBackgroundModes documentation - Update workmanager version to 0.9.0 in installation instructions Fixes #633 --- docs/quickstart.mdx | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx index 1e7d8d3b..0ad91d06 100644 --- a/docs/quickstart.mdx +++ b/docs/quickstart.mdx @@ -9,7 +9,7 @@ Add `workmanager` to your `pubspec.yaml`: ```yaml dependencies: - workmanager: ^0.8.0 + workmanager: ^0.9.0 ``` Then run: @@ -45,19 +45,19 @@ For regular data sync, notifications, cleanup - uses iOS Background Fetch: #### Option B: Processing Tasks (For complex operations) For file uploads, data processing, longer tasks - uses BGTaskScheduler: -1. **Enable Background Modes** in Xcode target capabilities ([Xcode Help](https://help.apple.com/xcode/mac/current/#/devbfa1532c4)) and add to Info.plist: +1. **Enable Background Modes** in Xcode target capabilities ([Xcode Help](https://help.apple.com/xcode/mac/current/#/devbfa1532c4)) and configure Info.plist: ```xml -UIBackgroundModes - - processing - - + BGTaskSchedulerPermittedIdentifiers com.yourapp.processing_task ``` + +**Note on UIBackgroundModes:** BGTaskScheduler processing tasks don't require a UIBackgroundModes entry. The `processing` value is not a valid UIBackgroundModes option. Only add `BGTaskSchedulerPermittedIdentifiers` to enable processing tasks. See [Apple's UIBackgroundModes documentation](https://developer.apple.com/documentation/bundleresources/information-property-list/uibackgroundmodes) for valid background modes. + + 2. **Configure AppDelegate.swift** (required for BGTaskScheduler): ```swift import workmanager_apple @@ -75,13 +75,9 @@ WorkmanagerPlugin.registerBGProcessingTask( #### Option C: Periodic Tasks with Custom Frequency For periodic tasks with more control than Background Fetch - uses BGTaskScheduler with frequency: -1. **Enable Background Modes** in Xcode target capabilities ([Xcode Help](https://help.apple.com/xcode/mac/current/#/devbfa1532c4)) and add to Info.plist: +1. **Configure Info.plist** for BGTaskScheduler: ```xml -UIBackgroundModes - - processing - - + BGTaskSchedulerPermittedIdentifiers com.yourapp.periodic_task From 35b4573a32cbbd5063b4017f38b4a4ed79190933 Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Tue, 5 Aug 2025 22:15:03 +0100 Subject: [PATCH 3/6] Revert "docs: fix incorrect UIBackgroundModes documentation" This reverts commit 7116f5f234969a662f62440590843b03c21639eb. --- docs/quickstart.mdx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx index 0ad91d06..1e7d8d3b 100644 --- a/docs/quickstart.mdx +++ b/docs/quickstart.mdx @@ -9,7 +9,7 @@ Add `workmanager` to your `pubspec.yaml`: ```yaml dependencies: - workmanager: ^0.9.0 + workmanager: ^0.8.0 ``` Then run: @@ -45,19 +45,19 @@ For regular data sync, notifications, cleanup - uses iOS Background Fetch: #### Option B: Processing Tasks (For complex operations) For file uploads, data processing, longer tasks - uses BGTaskScheduler: -1. **Enable Background Modes** in Xcode target capabilities ([Xcode Help](https://help.apple.com/xcode/mac/current/#/devbfa1532c4)) and configure Info.plist: +1. **Enable Background Modes** in Xcode target capabilities ([Xcode Help](https://help.apple.com/xcode/mac/current/#/devbfa1532c4)) and add to Info.plist: ```xml - +UIBackgroundModes + + processing + + BGTaskSchedulerPermittedIdentifiers com.yourapp.processing_task ``` - -**Note on UIBackgroundModes:** BGTaskScheduler processing tasks don't require a UIBackgroundModes entry. The `processing` value is not a valid UIBackgroundModes option. Only add `BGTaskSchedulerPermittedIdentifiers` to enable processing tasks. See [Apple's UIBackgroundModes documentation](https://developer.apple.com/documentation/bundleresources/information-property-list/uibackgroundmodes) for valid background modes. - - 2. **Configure AppDelegate.swift** (required for BGTaskScheduler): ```swift import workmanager_apple @@ -75,9 +75,13 @@ WorkmanagerPlugin.registerBGProcessingTask( #### Option C: Periodic Tasks with Custom Frequency For periodic tasks with more control than Background Fetch - uses BGTaskScheduler with frequency: -1. **Configure Info.plist** for BGTaskScheduler: +1. **Enable Background Modes** in Xcode target capabilities ([Xcode Help](https://help.apple.com/xcode/mac/current/#/devbfa1532c4)) and add to Info.plist: ```xml - +UIBackgroundModes + + processing + + BGTaskSchedulerPermittedIdentifiers com.yourapp.periodic_task From 2ffb3162c811a6e18d39a84ad0746bde148899ee Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Tue, 5 Aug 2025 22:15:24 +0100 Subject: [PATCH 4/6] docs: improve iOS background modes documentation links - Replace Xcode Help link with Apple's Configuration Guide - Add link to UIBackgroundModes property list documentation - Provide both practical configuration and technical reference links Fixes #633 --- docs/quickstart.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx index 1e7d8d3b..11437995 100644 --- a/docs/quickstart.mdx +++ b/docs/quickstart.mdx @@ -28,7 +28,7 @@ iOS requires a 5-minute setup in Xcode. Choose your approach based on your needs #### Option A: Periodic Tasks (Recommended for most use cases) For regular data sync, notifications, cleanup - uses iOS Background Fetch: -1. **Enable Background Modes** in Xcode target capabilities ([Xcode Help](https://help.apple.com/xcode/mac/current/#/devbfa1532c4)) and add to Info.plist: +1. **Enable Background Modes** in Xcode target capabilities ([Configuration Guide](https://developer.apple.com/documentation/xcode/configuring-background-execution-modes)) and add to Info.plist ([UIBackgroundModes reference](https://developer.apple.com/documentation/bundleresources/information-property-list/uibackgroundmodes)): ```xml UIBackgroundModes @@ -45,7 +45,7 @@ For regular data sync, notifications, cleanup - uses iOS Background Fetch: #### Option B: Processing Tasks (For complex operations) For file uploads, data processing, longer tasks - uses BGTaskScheduler: -1. **Enable Background Modes** in Xcode target capabilities ([Xcode Help](https://help.apple.com/xcode/mac/current/#/devbfa1532c4)) and add to Info.plist: +1. **Enable Background Modes** in Xcode target capabilities ([Configuration Guide](https://developer.apple.com/documentation/xcode/configuring-background-execution-modes)) and add to Info.plist ([UIBackgroundModes reference](https://developer.apple.com/documentation/bundleresources/information-property-list/uibackgroundmodes)): ```xml UIBackgroundModes @@ -75,7 +75,7 @@ WorkmanagerPlugin.registerBGProcessingTask( #### Option C: Periodic Tasks with Custom Frequency For periodic tasks with more control than Background Fetch - uses BGTaskScheduler with frequency: -1. **Enable Background Modes** in Xcode target capabilities ([Xcode Help](https://help.apple.com/xcode/mac/current/#/devbfa1532c4)) and add to Info.plist: +1. **Enable Background Modes** in Xcode target capabilities ([Configuration Guide](https://developer.apple.com/documentation/xcode/configuring-background-execution-modes)) and add to Info.plist ([UIBackgroundModes reference](https://developer.apple.com/documentation/bundleresources/information-property-list/uibackgroundmodes)): ```xml UIBackgroundModes From 7b8123b36c1b3f5b3047eab05a231ecd7f0e8b8c Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Tue, 5 Aug 2025 22:31:01 +0100 Subject: [PATCH 5/6] fix: prevent NullPointerException in BackgroundWorker.getDartTask - Remove non-null assertion operator (!!) from dartTask property - Add null checks in all methods that use dartTask - Handle null dart task gracefully with proper error reporting - Fixes crash when DART_TASK_KEY is missing from worker input data Fixes #635 --- example/ios/Podfile.lock | 13 +++++++ example/ios/Runner.xcodeproj/project.pbxproj | 4 +++ .../workmanager/BackgroundWorker.kt | 36 ++++++++++++++++--- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 63dad78d..68b19d82 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,33 +1,46 @@ PODS: - Flutter (1.0.0) + - integration_test (0.0.1): + - Flutter - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS - permission_handler_apple (9.3.0): - Flutter + - shared_preferences_foundation (0.0.1): + - Flutter + - FlutterMacOS - workmanager_apple (0.0.1): - Flutter DEPENDENCIES: - Flutter (from `Flutter`) + - integration_test (from `.symlinks/plugins/integration_test/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) + - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - workmanager_apple (from `.symlinks/plugins/workmanager_apple/ios`) EXTERNAL SOURCES: Flutter: :path: Flutter + integration_test: + :path: ".symlinks/plugins/integration_test/ios" path_provider_foundation: :path: ".symlinks/plugins/path_provider_foundation/darwin" permission_handler_apple: :path: ".symlinks/plugins/permission_handler_apple/ios" + shared_preferences_foundation: + :path: ".symlinks/plugins/shared_preferences_foundation/darwin" workmanager_apple: :path: ".symlinks/plugins/workmanager_apple/ios" SPEC CHECKSUMS: Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e path_provider_foundation: 608fcb11be570ce83519b076ab6a1fffe2474f05 permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d + shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7 workmanager_apple: 904529ae31e97fc5be632cf628507652294a0778 PODFILE CHECKSUM: 1959d098c91d8a792531a723c4a9d7e9f6a01e38 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 01efe3a0..485a9645 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -369,12 +369,16 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/integration_test/integration_test.framework", "${BUILT_PRODUCTS_DIR}/path_provider_foundation/path_provider_foundation.framework", + "${BUILT_PRODUCTS_DIR}/shared_preferences_foundation/shared_preferences_foundation.framework", "${BUILT_PRODUCTS_DIR}/workmanager_apple/workmanager_apple.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/integration_test.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_foundation.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_foundation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/workmanager_apple.framework", ); runOnlyForDeploymentPostprocessing = 0; diff --git a/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt b/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt index ef2a37ad..367b3bd7 100644 --- a/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt +++ b/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/BackgroundWorker.kt @@ -46,7 +46,7 @@ class BackgroundWorker( } private val dartTask - get() = workerParams.inputData.getString(DART_TASK_KEY)!! + get() = workerParams.inputData.getString(DART_TASK_KEY) private val runAttemptCount = workerParams.runAttemptCount private val randomThreadIdentifier = Random().nextInt() @@ -86,11 +86,20 @@ class BackgroundWorker( return@ensureInitializationCompleteAsync } + val localDartTask = dartTask + + if (localDartTask == null) { + val exception = IllegalStateException("Dart task is null") + WorkmanagerDebug.onExceptionEncountered(applicationContext, null, exception) + completer?.set(Result.failure()) + return@ensureInitializationCompleteAsync + } + val dartBundlePath = flutterLoader.findAppBundlePath() val taskInfo = TaskDebugInfo( - taskName = dartTask, + taskName = localDartTask, inputData = payload, startTime = startTime, callbackHandle = callbackHandle, @@ -132,9 +141,18 @@ class BackgroundWorker( ) { val fetchDuration = System.currentTimeMillis() - startTime + val localDartTask = dartTask + + if (localDartTask == null) { + val exception = IllegalStateException("Dart task is null") + WorkmanagerDebug.onExceptionEncountered(applicationContext, null, exception) + completer?.set(Result.failure()) + return + } + val taskInfo = TaskDebugInfo( - taskName = dartTask, + taskName = localDartTask, inputData = payload, startTime = startTime, ) @@ -175,7 +193,17 @@ class BackgroundWorker( // Convert payload to the format expected by Pigeon (Map) val pigeonPayload = payload.mapKeys { it.key as String? }.mapValues { it.value as Object? } - flutterApi.executeTask(dartTask, pigeonPayload) { result -> + val localDartTask = dartTask + + if (localDartTask == null) { + val exception = IllegalStateException("Dart task is null") + WorkmanagerDebug.onExceptionEncountered(applicationContext, null, exception) + + stopEngine(Result.failure(), exception.message) + return + } + + flutterApi.executeTask(localDartTask, pigeonPayload) { result -> when { result.isSuccess -> { val wasSuccessful = result.getOrNull() ?: false From edc38fd55675ebab55c87d81e841ac0f846e1a37 Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Tue, 5 Aug 2025 22:41:08 +0100 Subject: [PATCH 6/6] Revert "chore(release): publish packages" This reverts commit aa9e3b69665f3c163391e5524a33ae052227c2cd. --- CHANGELOG.md | 28 ---------------------------- workmanager/CHANGELOG.md | 4 ---- workmanager/pubspec.yaml | 4 ++-- workmanager_apple/CHANGELOG.md | 4 ---- workmanager_apple/pubspec.yaml | 2 +- 5 files changed, 3 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ca6dfe0..65459744 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,34 +3,6 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -## 2025-08-01 - -### Changes - ---- - -Packages with breaking changes: - - - There are no breaking changes in this release. - -Packages with other changes: - - - [`workmanager_apple` - `v0.9.1`](#workmanager_apple---v091) - - [`workmanager` - `v0.9.0+1`](#workmanager---v0901) - -Packages with dependency updates only: - -> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. - - - `workmanager` - `v0.9.0+1` - ---- - -#### `workmanager_apple` - `v0.9.1` - - - **FEAT**: add iOS Swift Package Manager support (#631). - - ## 2025-07-31 ### Changes diff --git a/workmanager/CHANGELOG.md b/workmanager/CHANGELOG.md index 4f1a85e3..e8ea30fe 100644 --- a/workmanager/CHANGELOG.md +++ b/workmanager/CHANGELOG.md @@ -1,7 +1,3 @@ -## 0.9.0+1 - - - Update a dependency to the latest release. - ## 0.9.0 > Note: This release has breaking changes. diff --git a/workmanager/pubspec.yaml b/workmanager/pubspec.yaml index 7bf4c914..e242544a 100644 --- a/workmanager/pubspec.yaml +++ b/workmanager/pubspec.yaml @@ -1,6 +1,6 @@ name: workmanager description: Flutter Workmanager. This plugin allows you to schedule background work on Android and iOS. -version: 0.9.0+1 +version: 0.9.0 # publish_to: none homepage: https://github.com/fluttercommunity/flutter_workmanager repository: https://github.com/fluttercommunity/flutter_workmanager @@ -15,7 +15,7 @@ dependencies: sdk: flutter workmanager_platform_interface: ^0.9.0 workmanager_android: ^0.9.0 - workmanager_apple: ^0.9.1 + workmanager_apple: ^0.9.0 dev_dependencies: test: ^1.25.15 diff --git a/workmanager_apple/CHANGELOG.md b/workmanager_apple/CHANGELOG.md index 04a2ec72..e495f64c 100644 --- a/workmanager_apple/CHANGELOG.md +++ b/workmanager_apple/CHANGELOG.md @@ -1,7 +1,3 @@ -## 0.9.1 - - - **FEAT**: add iOS Swift Package Manager support (#631). - ## 0.9.0 > Note: This release has breaking changes. diff --git a/workmanager_apple/pubspec.yaml b/workmanager_apple/pubspec.yaml index a3227c0f..0f433506 100644 --- a/workmanager_apple/pubspec.yaml +++ b/workmanager_apple/pubspec.yaml @@ -1,6 +1,6 @@ name: workmanager_apple description: Apple platform (iOS/macOS) implementation of the workmanager plugin. -version: 0.9.1 +version: 0.9.0 # publish_to: none homepage: https://github.com/fluttercommunity/flutter_workmanager repository: https://github.com/fluttercommunity/flutter_workmanager