Skip to content

Add Swift Package Manager support for iOS platform#359

Open
danyabdo94 wants to merge 1 commit into
fluttercandies:mainfrom
danyabdo94:feature/add-spm-support
Open

Add Swift Package Manager support for iOS platform#359
danyabdo94 wants to merge 1 commit into
fluttercandies:mainfrom
danyabdo94:feature/add-spm-support

Conversation

@danyabdo94
Copy link
Copy Markdown

Summary

  • Add Package.swift and SPM-compatible source layout in packages/flutter_image_compress_common/ios/flutter_image_compress_common/
  • Existing CocoaPods structure in ios/Classes/ is preserved for backward compatibility
  • SPM dependencies: Mantle, SDWebImage, SDWebImageWebPCoder
  • Converts framework-style imports (#import <Mantle/Mantle.h>) to @import Mantle; for SPM module compatibility
  • Adds explicit #import <UIKit/UIKit.h> where needed (SPM doesn't provide prefix headers)

Context

Flutter now supports Swift Package Manager as a native dependency resolution mechanism. Plugins that provide a Package.swift in their ios/<plugin_name>/ directory are automatically resolved via SPM, eliminating the need for CocoaPods fallback.

Without SPM support, Flutter falls back to CocoaPods for the entire project when even a single plugin lacks a Package.swift, which blocks projects from migrating to a pure SPM build.

Test plan

  • flutter build ios succeeds with SPM enabled (flutter config --enable-swift-package-manager)
  • Zero CocoaPods fallback warnings in build output
  • Image compression and WebP encoding work correctly at runtime
  • flutter build ios --release produces a valid IPA (54.2MB)

🤖 Generated with Claude Code

Adds Package.swift and SPM-compatible source layout alongside existing
CocoaPods structure for the iOS platform package.

Dependencies (Mantle, SDWebImage, SDWebImageWebPCoder) are declared as
SPM packages. Framework-style imports are converted to @import for SPM
module compatibility, and explicit UIKit imports are added since SPM
doesn't provide prefix headers.
@danyabdo94 danyabdo94 requested a review from CaiJingLong as a code owner May 8, 2026 14:54
@alejandro-all-win-software
Copy link
Copy Markdown

Duplicated of #338

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.

2 participants