Skip to content

fix(workmanager_apple): Correct SPM structure and product name for Flutter compatibility#657

Open
IwO30 wants to merge 1 commit into
fluttercommunity:mainfrom
IwO30:fix/spm-product-name-and-structure
Open

fix(workmanager_apple): Correct SPM structure and product name for Flutter compatibility#657
IwO30 wants to merge 1 commit into
fluttercommunity:mainfrom
IwO30:fix/spm-product-name-and-structure

Conversation

@IwO30

@IwO30 IwO30 commented Dec 1, 2025

Copy link
Copy Markdown

Summary

This PR fixes Swift Package Manager (SPM) integration with Flutter's plugin system for workmanager_apple.

Problem

Flutter's SPM integration expects:

  1. Package.swift at ios/<plugin_name>/Package.swift (not directly in ios/)
  2. Product names with hyphens (e.g., workmanager-apple) not underscores (workmanager_apple)

Without these fixes, Flutter falls back to CocoaPods instead of using SPM, even when SPM is enabled.

Changes

  • Move Package.swift to ios/workmanager_apple/ subdirectory (Flutter SPM requirement)
  • Rename product from workmanager_apple to workmanager-apple (Flutter naming convention)
  • Add missing UIKit import in Extensions.swift for UIBackgroundFetchResult
  • Move Sources, Resources, Assets to correct subdirectory

Testing

  • Tested with Flutter 3.24+ with SPM enabled (flutter config --enable-swift-package-manager)
  • iOS build succeeds without CocoaPods fallback
  • All 16 iOS plugins now use SPM exclusively

Related

This follows the same pattern as other Flutter plugins with SPM support (e.g., flutter-secure-storage-darwin, path-provider-foundation, etc.)

@docs-page

docs-page Bot commented Dec 1, 2025

Copy link
Copy Markdown

To view this pull requests documentation preview, visit the following URL:

docs.page/fluttercommunity/flutter_workmanager~657

Documentation is deployed and generated using docs.page.

…utter compatibility

- Move Package.swift to ios/workmanager_apple/ subdirectory (Flutter SPM requirement)
- Rename product from 'workmanager_apple' to 'workmanager-apple' (Flutter naming convention)
- Add missing UIKit import in Extensions.swift for UIBackgroundFetchResult
- Move Sources, Resources, Assets to correct subdirectory

This fixes Swift Package Manager integration with Flutter's SPM plugin system,
which expects:
1. Package.swift at ios/<plugin_name>/Package.swift
2. Product names with hyphens (e.g., 'workmanager-apple' not 'workmanager_apple')

Without these fixes, Flutter falls back to CocoaPods instead of using SPM.
@martin-ideeri

Copy link
Copy Markdown

Bump, could we merge this ?

@patrikbadanjak

Copy link
Copy Markdown

I am still getting a warning after implementing this PR as my workmanager dependency that workmanager_apple doesn't support SPM

@IwO30

IwO30 commented Jun 11, 2026

Copy link
Copy Markdown
Author

@martin-ideeri I'd love to, but I don't have merge rights on this repo — this needs a maintainer to merge. From my side it's ready: all checks pass and there are no conflicts with the base branch.

@IwO30

IwO30 commented Jun 11, 2026

Copy link
Copy Markdown
Author

@patrikbadanjak The structure in this PR is correct — it matches Flutter's own federated plugins (e.g. path_provider_foundation also uses the hyphenated product name path-provider-foundation with an underscore target). The reason you still see the warning is almost certainly dependency resolution:

The umbrella workmanager package depends on workmanager_apple: ^0.9.1+2, which resolves from pub.dev — i.e. without this fix. So if you only override workmanager to point at this branch, pub still pulls the published workmanager_apple transitively, and the warning stays.

You have to override workmanager_apple explicitly as well:

dependency_overrides:
  workmanager:
    git:
      url: https://github.com/IwO30/flutter_workmanager.git
      ref: fix/spm-product-name-and-structure
      path: workmanager
  workmanager_apple:
    git:
      url: https://github.com/IwO30/flutter_workmanager.git
      ref: fix/spm-product-name-and-structure
      path: workmanager_apple

Then: flutter clean, delete ios/Podfile.lock and ios/.symlinks, run flutter pub get, and rebuild.

Could you confirm whether you had workmanager_apple overridden too? If only workmanager was overridden, that would fully explain the persisting warning.

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