From ac2b65831112a9b116f86ea4bbef7d1d3afbe78a Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Sat, 30 Aug 2025 13:37:49 +0100 Subject: [PATCH 1/4] fix: Android initialization bug and iOS 14 availability annotations - Fix Android PlatformException on first run after initialize (fixes #645) - Update currentDispatcherHandle when initialize() is called - Add validation for callback handle - Add iOS 14.0 availability annotation to LoggingDebugHandler (fixes #641) - Prevents build errors when os.Logger is used - Update documentation with iOS 14.0 minimum deployment target requirement (fixes #639) Co-Authored-By: Claude --- docs/quickstart.mdx | 9 +++++++++ .../workmanager/WorkmanagerPlugin.kt | 15 ++++++++++++++- .../workmanager_apple/LoggingDebugHandler.swift | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx index 11437995..a54d114f 100644 --- a/docs/quickstart.mdx +++ b/docs/quickstart.mdx @@ -23,6 +23,15 @@ flutter pub get Android works automatically - no additional setup required! ✅ ### iOS + + +**iOS Minimum Deployment Target:** iOS 14.0 or later is required. Update your project's deployment target in Xcode: +1. Open `ios/Runner.xcodeproj` in Xcode +2. Select the Runner target +3. Set "Minimum Deployments" to iOS 14.0 or later +4. Or edit `ios/Runner.xcodeproj/project.pbxproj` and set `IPHONEOS_DEPLOYMENT_TARGET = 14.0;` + + iOS requires a 5-minute setup in Xcode. Choose your approach based on your needs: #### Option A: Periodic Tasks (Recommended for most use cases) diff --git a/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt b/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt index 4799ada1..9c3de8d2 100644 --- a/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt +++ b/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt @@ -47,7 +47,20 @@ class WorkmanagerPlugin : callback: (Result) -> Unit, ) { try { - preferenceManager.saveCallbackDispatcherHandleKey(request.callbackHandle) + val handle = request.callbackHandle + + // Validate the handle + if (handle <= 0L) { + callback(Result.failure(Exception("Invalid callback handle provided to initialize"))) + return + } + + // Save to SharedPreferences + preferenceManager.saveCallbackDispatcherHandleKey(handle) + + // Update the local variable to match + currentDispatcherHandle = handle + callback(Result.success(Unit)) } catch (e: Exception) { callback(Result.failure(e)) diff --git a/workmanager_apple/ios/Sources/workmanager_apple/LoggingDebugHandler.swift b/workmanager_apple/ios/Sources/workmanager_apple/LoggingDebugHandler.swift index 7966251e..2394e07c 100644 --- a/workmanager_apple/ios/Sources/workmanager_apple/LoggingDebugHandler.swift +++ b/workmanager_apple/ios/Sources/workmanager_apple/LoggingDebugHandler.swift @@ -3,7 +3,9 @@ import os /** * A debug handler that outputs debug information to iOS's unified logging system. + * Note: This class requires iOS 14.0 or later due to the use of os.Logger. */ +@available(iOS 14.0, *) public class LoggingDebugHandler: WorkmanagerDebug { private let logger = os.Logger(subsystem: "dev.fluttercommunity.workmanager", category: "debug") From b38ca82df841a4f3b87f3eb3142f4b63daedfa09 Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Sat, 30 Aug 2025 13:45:10 +0100 Subject: [PATCH 2/4] docs: add version management guidelines for melos workflow --- CLAUDE.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index c5389f1c..34e6e35d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,3 +1,12 @@ +## Version Management +- **DO NOT manually edit CHANGELOG.md files** - Melos handles changelog generation automatically +- **Use semantic commit messages** for proper versioning: + - `fix:` for bug fixes (patch version bump) + - `feat:` for new features (minor version bump) + - `BREAKING CHANGE:` or `!` for breaking changes (major version bump) + - Example: `fix: prevent iOS build errors with Logger availability` +- Melos will generate changelog entries from commit messages during release + ## Pre-Commit Requirements **CRITICAL**: Always run from project root before ANY commit: 1. `dart analyze` (check for code errors) From 272779ef34aa0b890406b6b2458801aeda6b1d76 Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Sat, 30 Aug 2025 13:51:21 +0100 Subject: [PATCH 3/4] chore: regenerate pigeon files after pub upgrade --- .../dev/fluttercommunity/workmanager/pigeon/WorkmanagerApi.g.kt | 2 +- .../ios/Sources/workmanager_apple/pigeon/WorkmanagerApi.g.swift | 2 +- .../lib/src/pigeon/workmanager_api.g.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/pigeon/WorkmanagerApi.g.kt b/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/pigeon/WorkmanagerApi.g.kt index 8d9ec9a1..f274eeac 100644 --- a/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/pigeon/WorkmanagerApi.g.kt +++ b/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/pigeon/WorkmanagerApi.g.kt @@ -1,7 +1,7 @@ // // Copyright 2024 The Flutter Workmanager Authors. All rights reserved. // // Use of this source code is governed by a MIT-style license that can be // // found in the LICENSE file. -// Autogenerated from Pigeon (v26.0.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon @file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") diff --git a/workmanager_apple/ios/Sources/workmanager_apple/pigeon/WorkmanagerApi.g.swift b/workmanager_apple/ios/Sources/workmanager_apple/pigeon/WorkmanagerApi.g.swift index 7ed61adb..b5b845ad 100644 --- a/workmanager_apple/ios/Sources/workmanager_apple/pigeon/WorkmanagerApi.g.swift +++ b/workmanager_apple/ios/Sources/workmanager_apple/pigeon/WorkmanagerApi.g.swift @@ -1,7 +1,7 @@ // // Copyright 2024 The Flutter Workmanager Authors. All rights reserved. // // Use of this source code is governed by a MIT-style license that can be // // found in the LICENSE file. -// Autogenerated from Pigeon (v26.0.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation diff --git a/workmanager_platform_interface/lib/src/pigeon/workmanager_api.g.dart b/workmanager_platform_interface/lib/src/pigeon/workmanager_api.g.dart index 780c357d..75474851 100644 --- a/workmanager_platform_interface/lib/src/pigeon/workmanager_api.g.dart +++ b/workmanager_platform_interface/lib/src/pigeon/workmanager_api.g.dart @@ -1,7 +1,7 @@ // // Copyright 2024 The Flutter Workmanager Authors. All rights reserved. // // Use of this source code is governed by a MIT-style license that can be // // found in the LICENSE file. -// Autogenerated from Pigeon (v26.0.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers From 61adb41f6544fc305067ab546cf4171007d3a087 Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Sun, 31 Aug 2025 00:53:44 +0100 Subject: [PATCH 4/4] fix: remove invalid handle validation that was rejecting valid callback handles The handle validation was too strict and incorrectly rejected valid callback handles (including 0) which caused all initialize calls to fail in integration tests --- .../dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt b/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt index 9c3de8d2..d7774bcc 100644 --- a/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt +++ b/workmanager_android/android/src/main/kotlin/dev/fluttercommunity/workmanager/WorkmanagerPlugin.kt @@ -49,12 +49,6 @@ class WorkmanagerPlugin : try { val handle = request.callbackHandle - // Validate the handle - if (handle <= 0L) { - callback(Result.failure(Exception("Invalid callback handle provided to initialize"))) - return - } - // Save to SharedPreferences preferenceManager.saveCallbackDispatcherHandleKey(handle)