Skip to content

fix: guard FlutterTaskQueue for backward compatibility - #117

Merged
muzahidul-opti merged 5 commits into
masterfrom
fix/flutter-task-queue-compat
Aug 24, 2026
Merged

fix: guard FlutterTaskQueue for backward compatibility#117
muzahidul-opti merged 5 commits into
masterfrom
fix/flutter-task-queue-compat

Conversation

@muzahidul-opti

Copy link
Copy Markdown
Contributor

Summary

  • Guards makeBackgroundTaskQueue call with responds(to:) in SwiftOptimizelyFlutterSdkPlugin.register(with:) to support older Flutter versions (< 3.22) where FlutterTaskQueue protocol is incomplete
  • Falls back to creating the logger FlutterMethodChannel without a taskQueue when the API is unavailable
  • Adds spec document at specs/002-flutter-task-queue-compat/spec.md

Context

The testapp iOS CI uses Flutter 3.16.0 with Xcode 26.6. At this combination, the Swift compiler cannot import makeBackgroundTaskQueue because the FlutterTaskQueue protocol is forward-declared but not fully defined in the ObjC header. This causes two hard compilation errors:

error: value of type 'any FlutterBinaryMessenger' has no member 'makeBackgroundTaskQueue'
error: extra argument 'taskQueue' in call

The taskQueue parameter is an optimization (offloads logger callbacks from the main thread). Passing nil falls back to the default behavior with no functional regression.

Test plan

  • Testapp iOS CI passes with Flutter 3.16.0 + Xcode 26.6
  • Local build succeeds with Flutter 3.44.0 + Xcode 26.6 (taskQueue path taken)
  • flutter test passes (no Dart changes)

🤖 Generated with Claude Code

muzahidul-opti and others added 2 commits August 22, 2026 07:10
FlutterTaskQueue protocol is incomplete in Flutter < 3.22 headers,
causing Swift compilation errors with modern Xcode (26.6+). Use
responds(to:) to fall back gracefully when the API is unavailable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The responds(to:) guard was insufficient — Swift rejects the code at
compile time because FlutterTaskQueue is an incomplete protocol in
older Flutter headers. Remove makeBackgroundTaskQueue usage entirely;
the logger already dispatches to main thread via DispatchQueue.main.async.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@muzahidul-opti

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

…eue-compat

Co-authored-by: muzahidul-opti <129880873+muzahidul-opti@users.noreply.github.com>

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merged master into this branch — no conflicts, the merge applied cleanly.

@muzahidul-opti

Copy link
Copy Markdown
Contributor Author

@copilot review the pr

Co-authored-by: muzahidul-opti <129880873+muzahidul-opti@users.noreply.github.com>

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

@copilot review the pr

Review complete. The Swift fix is correct — makeBackgroundTaskQueue/taskQueue are fully removed from logger channel creation, and DispatchQueue.main.async in OptimizelyFlutterLogger already handles thread safety with no regression.

One spec doc inaccuracy was found and fixed (commit $(git rev-parse --short HEAD)): the "Solution" section was still describing the abandoned responds(to:) runtime-guard approach rather than the actual implementation. The spec now accurately documents dropping taskQueue entirely and the rationale for doing so.

@pvcraven pvcraven left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes logger/background task for backwards compatability.

@muzahidul-opti
muzahidul-opti merged commit 9573f43 into master Aug 24, 2026
9 of 10 checks passed
@muzahidul-opti
muzahidul-opti deleted the fix/flutter-task-queue-compat branch August 24, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants