Conversation
…ackage Manager support, removing old plugin files, and update example project dependencies and macOS deployment target.
…anager, update Xcode scheme, and app delegate.
|
I took the opportunity to correct the linter warnings using Flutter 3.41. |
|
Great PR! This update is crucial for Flutter compatibility. +1 for merging. Thx @vicajilau for the job |
There was a problem hiding this comment.
Pull request overview
Adds Swift Package Manager (SPM) support for the pasteboard Flutter plugin on iOS and macOS, updating the native plugin structure and example apps to validate SPM-based integration (Issue #462).
Changes:
- Introduces SwiftPM
Package.swiftmanifests and Swift sources for iOS/macOS plugin targets. - Updates CocoaPods podspecs to compile the SwiftPM source layout (and removes the iOS Obj-C registrar shim).
- Migrates the example iOS/macOS projects away from CocoaPods and updates project/scheme settings for SPM-based builds.
Reviewed changes
Copilot reviewed 22 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/pasteboard/macos/pasteboard/Sources/pasteboard/PasteboardPlugin.swift | New macOS Swift implementation for SPM/CocoaPods source layout. |
| packages/pasteboard/macos/pasteboard/Package.swift | New macOS SwiftPM manifest for the plugin. |
| packages/pasteboard/macos/pasteboard.podspec | Points CocoaPods at SwiftPM-style Sources/ Swift files. |
| packages/pasteboard/lib/src/pasteboard_platform_io.dart | Refactors temp filename helper; Windows writeImage path touched. |
| packages/pasteboard/ios/pasteboard/Sources/pasteboard/SwiftPasteboardPlugin.swift | Renames Swift plugin class to PasteboardPlugin to match pluginClass. |
| packages/pasteboard/ios/pasteboard/Package.swift | New iOS SwiftPM manifest for the plugin. |
| packages/pasteboard/ios/pasteboard.podspec | Points CocoaPods at SwiftPM-style Sources/ Swift files. |
| packages/pasteboard/ios/Classes/PasteboardPlugin.m | Removes legacy Obj-C registrar shim (now handled via @objc(PasteboardPlugin)). |
| packages/pasteboard/ios/Classes/PasteboardPlugin.h | Removes legacy Obj-C header for the registrar shim. |
| packages/pasteboard/example/pubspec.lock | Updates example’s resolved Dart/Flutter dependency lockfile. |
| packages/pasteboard/example/macos/Runner/AppDelegate.swift | Updates macOS app entry point to modern Swift @main + secure state support. |
| packages/pasteboard/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | Adds Flutter “prepare” pre-action and updates scheme settings for SPM workflows. |
| packages/pasteboard/example/macos/Runner.xcodeproj/project.pbxproj | Migrates macOS example project from Pods to FlutterGeneratedPluginSwiftPackage + bumps deployment target. |
| packages/pasteboard/example/macos/Podfile.lock | Removes CocoaPods lockfile from macOS example. |
| packages/pasteboard/example/macos/Podfile | Removes CocoaPods Podfile from macOS example. |
| packages/pasteboard/example/macos/Flutter/Flutter-Release.xcconfig | Removes Pods xcconfig include for macOS example. |
| packages/pasteboard/example/macos/Flutter/Flutter-Debug.xcconfig | Removes Pods xcconfig include for macOS example. |
| packages/pasteboard/example/ios/Runner/Info.plist | Updates iOS example Info.plist for newer Flutter/iOS project structure (scenes, etc.). |
| packages/pasteboard/example/ios/Runner/AppDelegate.swift | Updates iOS example AppDelegate for implicit engine initialization registration flow. |
| packages/pasteboard/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | Adds Flutter “prepare” pre-action and updates scheme settings for SPM workflows. |
| packages/pasteboard/example/ios/Runner.xcodeproj/project.pbxproj | Migrates iOS example project from Pods to FlutterGeneratedPluginSwiftPackage + bumps deployment target. |
| packages/pasteboard/example/ios/Podfile.lock | Removes CocoaPods lockfile from iOS example. |
| packages/pasteboard/example/ios/Podfile | Removes CocoaPods Podfile from iOS example. |
| packages/pasteboard/example/ios/Flutter/Release.xcconfig | Removes Pods xcconfig include for iOS example. |
| packages/pasteboard/example/ios/Flutter/Debug.xcconfig | Removes Pods xcconfig include for iOS example. |
| packages/pasteboard/example/ios/Flutter/AppFrameworkInfo.plist | Removes explicit MinimumOSVersion entry from framework plist. |
Comments suppressed due to low confidence (1)
packages/pasteboard/lib/src/pasteboard_platform_io.dart:73
- On Windows, this async method uses blocking IO (
writeAsBytesSync) and also callsfile.delete()without awaiting the returnedFuture, which can leave temp files behind (and may triggerunawaited_futureslints).
Prefer await file.writeAsBytes(image) and await file.delete() (or explicitly mark the delete as unawaited if that’s intentional).
final file = await File(_getTempFileName()).create();
file.writeAsBytesSync(image);
await _channel
.invokeMethod<Object>('writeImage', {'fileName': file.path});
file.delete();
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let package = Package( | ||
| name: "pasteboard", | ||
| platforms: [ | ||
| .iOS("9.0") |
There was a problem hiding this comment.
This SPM manifest declares .iOS("9.0"), but the iOS example app in this PR is now set to IPHONEOS_DEPLOYMENT_TARGET = 13.0 and other iOS examples in the repo commonly target 11.0+. This mismatch can make it unclear what the intended supported iOS baseline is for SPM consumers.
Consider raising the SwiftPM minimum iOS version to match the repo’s current iOS baseline (or document why it intentionally remains lower).
| .iOS("9.0") | |
| .iOS("13.0") |
There was a problem hiding this comment.
Based on the fact that this is a repository that houses different packages, you should focus on the pasteboard folder. This is because the versions of other packages are independent. If you look at the Cocoapods version on iOS for pasteboard in main, it is set to iOS 9.0.
| let package = Package( | ||
| name: "pasteboard", | ||
| platforms: [ | ||
| .macOS("10.11") |
There was a problem hiding this comment.
This SPM manifest declares .macOS("10.11"), but other SwiftPM-based macOS plugins in this repo (e.g. desktop_drop) declare 10.13+. Keeping this at 10.11 may be inconsistent with the repo’s supported macOS baseline and can complicate integration when combined with other plugins.
Consider aligning the minimum macOS version with the repo’s existing SwiftPM packages (likely 10.13 or higher).
| .macOS("10.11") | |
| .macOS("10.13") |
There was a problem hiding this comment.
Same here. If we look at the Cocoapods version on macOS for pasteboard in main, it is set to macOS 10.11.
This update adds support for the Pasteboard package in Swift Package Manager on both iOS and macOS. I have tested the integration on both iOS and macOS using CocoaPods and SPM.