Migrate workmanager_apple plugin to support Swift Package Manager (SPM) while maintaining full CocoaPods backward compatibility.
workmanager_apple/ios/
├── Assets/
├── Classes/
│ ├── BackgroundTaskOperation.swift
│ ├── BackgroundWorker.swift
│ ├── Extensions.swift
│ ├── LoggingDebugHandler.swift
│ ├── NotificationDebugHandler.swift
│ ├── SimpleLogger.swift
│ ├── ThumbnailGenerator.swift
│ ├── UserDefaultsHelper.swift
│ ├── WMPError.swift
│ ├── WorkmanagerDebugHandler.swift
│ ├── WorkmanagerPlugin.swift
│ └── pigeon/
│ └── WorkmanagerApi.g.swift
├── Resources/
│ └── PrivacyInfo.xcprivacy
└── workmanager_apple.podspec
- Create
workmanager_apple/ios/Package.swift - Create new directory structure:
workmanager_apple/ios/ ├── Sources/ │ └── workmanager_apple/ │ ├── include/ │ │ └── workmanager_apple-umbrella.h (if needed) │ └── [all .swift files moved here] └── Resources/ └── PrivacyInfo.xcprivacy
- Move Swift files from
Classes/toSources/workmanager_apple/ - Preserve pigeon structure as
Sources/workmanager_apple/pigeon/ - Update import statements if needed
- Handle resources - PrivacyInfo.xcprivacy
- Create Package.swift with proper target definitions
- Update podspec to reference new file locations
- Maintain backward compatibility for CocoaPods users
- Dual build testing in GitHub Actions
- CocoaPods build: Test existing workflow
- SPM build: New workflow for SPM validation
- Example app testing: Both dependency managers
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "workmanager_apple",
platforms: [
.iOS(.v14)
],
products: [
.library(name: "workmanager_apple", targets: ["workmanager_apple"])
],
targets: [
.target(
name: "workmanager_apple",
resources: [.process("Resources")]
)
]
)Matrix Strategy using Flutter SPM configuration:
- CocoaPods Build:
flutter config --no-enable-swift-package-manager+ build - SPM Build:
flutter config --enable-swift-package-manager+ build
Key Features:
- Flutter-native approach: Use
flutter configflags to switch dependency managers - Simple validation: Does example app build and run with both configurations?
- Matrix builds: Test both
--enable-swift-package-managerand--no-enable-swift-package-manager
GitHub Actions Matrix:
strategy:
matrix:
spm_enabled: [true, false]
include:
- spm_enabled: true
config_cmd: "flutter config --enable-swift-package-manager"
name: "SPM"
- spm_enabled: false
config_cmd: "flutter config --no-enable-swift-package-manager"
name: "CocoaPods"- Keep CocoaPods support indefinitely
- Update podspec paths to point to new locations
- Test both build systems in CI
- Maintain logical grouping of Swift files
- Preserve pigeon integration with generated files
- Handle resources properly in both systems
- No external Swift dependencies currently - simplifies migration
- Flutter framework dependency handled by both systems
- Current CocoaPods build works
- Example app builds and runs
- All functionality works on physical device
Simple test: Does the example app build and run with both dependency managers?
CocoaPods Build:
flutter config --no-enable-swift-package-manager
cd example && flutter build ios --debug --no-codesignSPM Build:
flutter config --enable-swift-package-manager
cd example && flutter build ios --debug --no-codesignFlutter Requirements:
- Flutter 3.24+ required for SPM support
- SPM is off by default, must be explicitly enabled
- Use Flutter's built-in SPM configuration flags
- Test both dependency managers via matrix builds
- No separate long-lived branches needed
- Create SPM-compliant directory structure
- Move all Swift files to
Sources/workmanager_apple/ - Update podspec to reference new locations
- Ensure CocoaPods + Pigeon still work
- Verification: Example app builds and runs with CocoaPods
- Add
Package.swiftwith proper configuration - Handle resources (PrivacyInfo.xcprivacy)
- Verification: Example app builds and runs with SPM
- Update GitHub Actions to test both dependency managers
- Use Flutter config flags for SPM/CocoaPods selection
- ✅ SPM support working in Flutter projects
- ✅ Full CocoaPods backward compatibility maintained
- ✅ All existing functionality preserved
- ✅ CI/CD tests both dependency managers
- ✅ No breaking changes for existing users
- ✅ Proper resource and privacy manifest handling