Repository navigation
fix(iOS): use literal target name in Package.swift instead of a let variable - #409
Merged
AlexV525 merged 2 commits intoOct 18, 2026
Conversation
…ariable Flutter's `flutter build swift-package` invokes `swift package add-target-dependency` to inject the FlutterFramework dependency into plugin manifests. That SwiftPM command edits Package.swift via syntactic source parsing rather than manifest evaluation, so it cannot resolve a target/product name expressed through a `let packageName` variable, failing with "unable to find target named 'flutter_image_compress_common' in package" even though the target exists. Using the literal string lets SwiftPM locate and edit the target correctly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
AlexV525
reviewed
Sep 11, 2026
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CaiJingLong
approved these changes
Oct 1, 2026
CaiJingLong
left a comment
Member
There was a problem hiding this comment.
Reviewed 8d2cf43. The literal target name addresses SwiftPM’s syntax-based target lookup, and the remaining substitutions preserve the package/product names and header search path. The earlier request to remove packageName has been addressed. No blocking findings.
All nine checks passed, including the iOS SwiftPM build and integration tests (18 passed, with two Android-only tests skipped). I did not rerun Swift/Flutter locally; the existing CI does not exercise the exact flutter build swift-package command.
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.
Problem
flutter build swift-package --platform iosfails on any app depending onflutter_image_compresswith:Root cause
Flutter's tooling injects the
FlutterFrameworkdependency into each plugin'sPackage.swiftby runningswift package add-target-dependency. That SwiftPM subcommand edits the manifest via syntactic source parsing, not evaluation — it can't resolve a target/product name expressed through alet packageName = "..."variable, even thoughswift package dump-package(which evaluates the manifest) resolves it fine.Confirmed in isolation, independent of this plugin: a minimal
Package.swiftusing.target(name: packageName)fails the sameadd-target-dependencycall with the same error; switching to a literal.target(name: "Foo")succeeds.Fix
Replace the
packageNamevariable with literal strings.Test plan
swift package dump-packagestill parses the manifest correctly.swift package add-target-dependency FlutterFramework flutter_image_compress_commonnow succeeds (previously failed).fvm flutter build swift-package --platform iosproceeds past this plugin.🤖 Generated with Claude Code