fix(iOS/SPM): hyphenate library product name + missing UIKit imports (issue #52) — v1.4.2#53
Merged
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #52.
What
Package.swiftlibrary product renamednative_workmanager→native-workmanager. Flutter's generatedFlutterGeneratedPluginSwiftPackagereferences every plugin by the hyphenated product name (plugin.name.replaceAll('_', '-')in flutter_tools'swift_package_manager.dart— SwiftPM uses the product name asCFBundleIdentifierwhen 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).Missing
import UIKitinCryptoWorker+FileSystemWorker. Both useUIApplication.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.Release process: scratch-app SPM build added to CONTRIBUTING. Both [iOS/SPM] Swift Package Manager build fails — local
.binaryTargetforKMPWorkManager.xcframeworkis never populated on pub.dev installs #49 and [iOS/SPM] SwiftPM resolve fails — library product is namednative_workmanagerbut Flutter references the hyphenated productnative-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-managerand this plugin as a path dep.Verification
product 'native-workmanager' … not found in package 'native_workmanager'.✓ Built build/ios/iphonesimulator/Runner.app.swift_package_manager.dart:151), not just the report.flutter analyze0 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.