Skip to content

fix(iOS/SPM): hyphenate library product name + missing UIKit imports (issue #52) — v1.4.2#53

Merged
vietnguyentuan2019 merged 2 commits into
mainfrom
fix/spm-hyphenated-product-issue-52
Jul 17, 2026
Merged

fix(iOS/SPM): hyphenate library product name + missing UIKit imports (issue #52) — v1.4.2#53
vietnguyentuan2019 merged 2 commits into
mainfrom
fix/spm-hyphenated-product-issue-52

Conversation

@vietnguyentuan2019

Copy link
Copy Markdown
Contributor

Closes #52.

What

  1. Package.swift library product renamed native_workmanagernative-workmanager. Flutter's generated FlutterGeneratedPluginSwiftPackage references every plugin by the hyphenated product name (plugin.name.replaceAll('_', '-') in flutter_tools' swift_package_manager.dart — SwiftPM uses the product name as CFBundleIdentifier when linking dynamically, and bundle ids can't contain underscores). With the underscored product, every SPM-enabled app failed resolution exactly as reported. Package name and target names keep underscores, matching the ecosystem convention (firebase_auth → firebase-auth, etc).

  2. Missing import UIKit in CryptoWorker + FileSystemWorker. Both use UIApplication.shared.beginBackgroundTask. CocoaPods compiled them via transitive module re-export; SwiftPM's stricter module isolation does not. Only surfaced once an SPM build actually compiled the plugin.

  3. Release process: scratch-app SPM build added to CONTRIBUTING. Both [iOS/SPM] Swift Package Manager build fails — local .binaryTarget for KMPWorkManager.xcframework is never populated on pub.dev installs #49 and [iOS/SPM] SwiftPM resolve fails — library product is named native_workmanager but Flutter references the hyphenated product native-workmanager #52 escaped because nothing consumed the package the way Flutter actually does. The new step builds a throwaway Flutter app with --enable-swift-package-manager and this plugin as a path dep.

Verification

  • Reproduced the exact error from the issue with a consumer package requesting the hyphenated product against 1.4.1's manifest: product 'native-workmanager' … not found in package 'native_workmanager'.
  • After the fix: scratch Flutter app (SwiftPM on, app deployment target raised to 14.0) builds end-to-end → ✓ Built build/ios/iphonesimulator/Runner.app.
  • Convention confirmed against flutter_tools source (swift_package_manager.dart:151), not just the report.
  • flutter analyze 0 issues; CocoaPods path untouched (podspec doesn't reference the SPM product name; CI's pod-based iOS build covers it).

Version

1.4.2 (pubspec + gen lockstep + podspec + doc snippets + changelogs). No Dart/Android changes.

…elease 1.4.2

Issue #52: Flutter's generated FlutterGeneratedPluginSwiftPackage references
plugins by the HYPHENATED product name (plugin.name.replaceAll('_', '-') in
flutter_tools swift_package_manager.dart — SwiftPM uses the product name as
CFBundleIdentifier for dynamic linking, which forbids underscores). Our
Package.swift exported the product as native_workmanager, so every SPM-enabled
app failed resolution: "product 'native-workmanager' … not found in package
'native_workmanager'". Product renamed to native-workmanager; package and
target names keep underscores.

Verified end-to-end with a scratch Flutter app (SwiftPM enabled, plugin as a
path dependency): reproduced the exact resolution error on 1.4.1, and the fix
builds through to '✓ Built Runner.app'. That E2E run also surfaced two workers
that never compiled under SPM — CryptoWorker and FileSystemWorker use
UIApplication without an explicit 'import UIKit' (CocoaPods compiled them via
transitive module re-export; SPM's module isolation does not). Imports added.

The scratch-app SPM build is now a documented release step in CONTRIBUTING —
both #49 and #52 escaped because nothing consumed the package the way Flutter
actually does.

Versions: 1.4.2 (pubspec, gen lockstep, podspec, doc snippets).
Format-only rewrap from Dart 3.11.5; both files sit outside the CI format
gate (which checks lib/ and test/ of the plugin and gen's lib/ only).
@vietnguyentuan2019
vietnguyentuan2019 merged commit dd3f2bd into main Jul 17, 2026
11 of 13 checks passed
@vietnguyentuan2019
vietnguyentuan2019 deleted the fix/spm-hyphenated-product-issue-52 branch July 17, 2026 04:18
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.

[iOS/SPM] SwiftPM resolve fails — library product is named native_workmanager but Flutter references the hyphenated product native-workmanager

1 participant