Skip to content

feat: migrate iOS/macOS to Swift Package Manager - #158

Merged
CaiJingLong merged 3 commits into
mainfrom
feat/spm-support
Oct 10, 2026
Merged

CaiJingLong merged 3 commits into
mainfrom
feat/spm-support

Conversation

@AlexV525

Copy link
Copy Markdown
Member

Summary

Migrate image_editor_common iOS and macOS native code to Swift Package Manager, following the same SPM layout as flutter_image_compress.

Changes

Source restructuring (iOS + macOS)

  • Classes/ → <platform>/image_editor_common/Sources/image_editor_common/*.m (flat)
  • Headers → Sources/image_editor_common/include/image_editor_common/*.h
  • Preserved as git mv (R100) — full history retained

Swift Package Manager

  • Added Package.swift for iOS (.iOS("9.0")) and macOS (.macOS("10.15"))
  • Product name image-editor-common, target image_editor_common
  • cSettings: [.headerSearchPath("include/image_editor_common")] for local header resolution
  • No pubspec swiftPackageManager key — Flutter auto-discovers Package.swift

Podspec compatibility

  • Both podspecs updated to reference the new Sources/ paths
  • CocoaPods builds remain fully functional (backward compatible)

Example & tooling

  • Example iOS project migrated for Flutter SPM integration
  • .gitignore: added **/.build/ and Flutter/ephemeral/

Verification

flutter build ios --debug --no-codesign
→ ✓ Built build/ios/iphoneos/Runner.app
→ Adding Swift Package Manager integration... (3.8s)
→ FlutterGeneratedPluginSwiftPackage resolves image_editor_common via SPM
→ image_editor_common NOT in Podfile.lock (confirmed via SPM)

Backward compatibility

Both CocoaPods and SPM paths work against the same source tree. The CI matrix here exercises the CocoaPods path; SPM can be verified locally with flutter config --enable-swift-package-manager.

Adopt the SPM layout used by flutter_image_compress:
- Move iOS sources to ios/image_editor_common/Sources/image_editor_common/
  (.m flat, .h under include/image_editor_common/)
- Move macOS sources to macos/image_editor_common/Sources/image_editor_common/
- Add Package.swift (iOS .iOS 9.0, macOS .macOS 10.15) with
  cSettings headerSearchPath, matching the podspec public_header layout
- Update both podspecs to reference the new Sources paths
- Add .build/ and Flutter/ephemeral/ to .gitignore
- Migrate example iOS project for Flutter SPM integration

The Package.swift product name 'image-editor-common' is auto-discovered
by Flutter's SPM tooling; no pubspec swiftPackageManager key needed.
- Finish migrating the example app to Swift Package Manager on iOS and macOS
- Wire FlutterGeneratedPluginSwiftPackage into the macOS Runner project
- Deintegrate CocoaPods: remove Podfiles, Pod build phases, and Pods xcworkspace refs
- Strip Pods-Runner.*.xcconfig includes from iOS/macOS Debug and Release xcconfigs
- Fix missing AppKit import in image_editor_common's macOS FIImport.h
- Refresh pubspec.lock and macOS AppDelegate.swift/scheme from flutter clean rebuild
feat: migrate example app to Swift Package Manager

@CaiJingLong CaiJingLong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 3ae6107 after #160 was merged into this branch. I reviewed the combined changes against main; no blocking library/API regression found.

The library retains Flutter >=2.10.0 / Dart >=2.12.0 and the existing CocoaPods deployment targets. Native source files are relocated without implementation changes apart from the necessary macOS AppKit import. CocoaPods source/header patterns match the new layout, and SwiftPM is an additional integration path. The newer example SDK/dependencies do not impose their lockfile requirement on consumers of the library.

Validation:

  • Confirmed this head's tracked tree is identical to 8a86cce, already built during #160 review: Flutter 3.44.0 strict example lockfile resolution and unsigned iOS/macOS Debug SwiftPM builds passed. Those builds used command-line iOS 15.0 / macOS 12.0 deployment-target overrides for Xcode 27.
  • Added a temporary independent Flutter 3.24.3 host with SwiftPM disabled and explicit local overrides for the repository packages. CocoaPods installed the relocated local image_editor_common sources and the macOS Debug build passed (macOS 12.0 override for Xcode 27). This tests the local native implementation, not a published copy from pub.dev.
  • Library dependency resolution/static analysis on Flutter 3.24.3, both podspec quick validations, the two platform-interface tests on Flutter 3.41.6, project/plist syntax, and git diff --check passed in this review session.
  • Inspected the latest failed Runnable CI log: the failure is the eight example API deprecations addressed by #159, not the native migration.

Limitations: GitHub CI is not wholly green, and some compatibility jobs have failed; this approval is not a claim that those jobs pass. Flutter 2.10, an old-SDK iOS CocoaPods build, and device runtime behavior were not fully tested. Keep the library minimum low and retain older-SDK coverage when fixing CI; do not solve example/toolchain failures by raising the library minimum.

@CaiJingLong
CaiJingLong merged commit b0403da into main Oct 10, 2026
16 of 22 checks passed
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.

3 participants