Skip to content

Exclude local Swift package schemes from --flavor error message - #191098

Merged
auto-submit[bot] merged 52 commits into
flutter:masterfrom
dhc-tech:fix-local-swiftpm-scheme-filtering
Sep 21, 2026
Merged

auto-submit[bot] merged 52 commits into
flutter:masterfrom
dhc-tech:fix-local-swiftpm-scheme-filtering

Conversation

@dhc-tech

@dhc-tech dhc-tech commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

When a developer mistypes a --flavor (e.g. flutter build ios --flavor Prdo), Flutter reports the available schemes so they can pick a valid one:

The Xcode project defines schemes: Runner, Amplitude-Swift, Foo-Dependency...
You must specify a --flavor option to select one of the available schemes.

XcodeProjectInfo already filters two kinds of non-flavor schemes out of this list: Flutter's own generated SwiftPM packages, and remote Swift package checkouts (packages fetched by SwiftPM into the build directory's checkouts folder). Xcode auto-merges each of those packages' own .xcscheme files into the host project's scheme list, even though they aren't declared in the host .xcodeproj and aren't real Flutter flavors.

What wasn't handled: local Swift packages — ones added directly to the Xcode project (an XCLocalSwiftPackageReference in project.pbxproj, e.g. living inside ios/) rather than fetched as a remote dependency. Those never appear under the checkouts directory, so their auto-merged schemes leaked straight through into definesCustomSchemes/schemes, and ended up quoted in the error message as if they were valid --flavor values.

This PR parses XCLocalSwiftPackageReference entries out of project.pbxproj, resolves each entry's relativePath against the host app root, and — for any local package that ships its own .swiftpm/xcode/xcshareddata/xcschemes/ directory — adds those scheme names to the same ignore set used for remote checkouts. The scheme-directory scan itself was already duplicated between the (new) local-package path and the existing remote-checkout path, so it's factored into one small shared helper.

Fixes #190098

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

XcodeProjectInfo already filters remote Swift package checkout schemes
and Flutter plugin schemes out of the scheme list shown when a
developer passes an invalid --flavor, but it did not account for local
Swift packages referenced directly from the host project's
project.pbxproj (XCLocalSwiftPackageReference). Xcode auto-merges those
packages' own schemes into the project's scheme list the same way it
does for remote checkouts, so they were leaking into the
'available schemes' error message as if they were valid flavors.

This parses XCLocalSwiftPackageReference entries out of
project.pbxproj, resolves each relativePath against the host app root,
and adds any schemes found under that package's
.swiftpm/xcode/xcshareddata/xcschemes directory to the ignore set —
mirroring the existing logic for remote checkouts, which is now shared
via a small helper.

Fixes flutter#190098
@dhc-tech
dhc-tech requested review from a team as code owners August 14, 2026 04:54
@github-actions github-actions Bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Aug 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for identifying and filtering local Swift package schemes in Xcode projects by parsing XCLocalSwiftPackageReference blocks within the project.pbxproj file, refactoring the scheme extraction logic into a shared helper method, and adding corresponding unit tests. The review feedback suggests making the regular expression for parsing these references more robust to accommodate other properties that Xcode may insert between fields, and updating the unit tests to verify this behavior.

dhc-tech and others added 5 commits August 14, 2026 10:25
Address gemini-code-assist review feedback: relativePath does not
necessarily immediately follow isa = XCLocalSwiftPackageReference; in
project.pbxproj, since Xcode may insert other properties (e.g. name,
customName) in between. Widen the match to allow any fields before
relativePath within the same object body, and add a customName field
to the regression test's fixture to cover this.
@hellohuanlin
hellohuanlin requested a review from vashworth August 20, 2026 21:58
vashworth
vashworth previously approved these changes Aug 27, 2026
@vashworth
vashworth requested a review from okorohelijah August 27, 2026 18:41
@github-actions

Copy link
Copy Markdown

This pull request targets the main branch, but the primary branch for this repository is master.

Please change the base branch of this pull request to master.

See: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request

@dhc-tech
dhc-tech changed the base branch from main to master August 30, 2026 06:23
@dhc-tech
dhc-tech dismissed vashworth’s stale review August 30, 2026 06:23

The base branch was changed.

@dhc-tech
dhc-tech requested a review from vashworth August 30, 2026 06:24
@vashworth vashworth added the CICD Run CI/CD label Sep 3, 2026
vashworth
vashworth previously approved these changes Sep 3, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 15, 2026
@dhc-tech

Copy link
Copy Markdown
Contributor Author

Hi @okorohelijah, just following up on this PR when you get a chance to take a look.

All checks have passed and @vashworth has already approved the changes. Since this requires a second review before autosubmit can trigger, let me know if there's anything else needed from my end. Thanks!

@vashworth vashworth added the CICD Run CI/CD label Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD platform-ios iOS applications specifically team-ios Owned by iOS platform team team-macos Owned by the macOS platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typing an invalid flavor incorrectly presents virtual SwiftPM dependencies as available Flutter flavors

3 participants