Skip to content

Flutter CLI ignores pubspec's Flutter features config (like SwiftPM) if current dir is not app's root #176294

Closed

Description

@Albert221

Steps:

  1. flutter create test_app --platforms ios and cd test_app
  2. flutter config --enable-swift-package-manager (because majority of my apps use it, or whatever reason)
  3. Add config: enable-swift-package-manager: false to pubspec (with proper indentations of course)
  4. flutter pub add firebase_core
  5. Run flutter pub get. cd ios/
  6. Update the first line of Podfile so that the minimum deployment target is "15.0", and uncomment the line (required by Firebase, unrelated to the bug).
  7. pod install. Check Podfile.lock, it contains the FirebaseCore (because we get it through Cocoapods)
  8. cd ios (or any other directory within the app's directory other than it), run flutter pub get. The config is ignored. Regenerate Podfile from symlinks with pod install. The FirebaseCore was removed from the lock, as it's fetched from SwiftPM now and not Cocoapods 🙃

The lines below sound like they have some knowledge of why it's happening. It should check the manifest of the package closest in the directory tree, not the current directory.

// Can be null if no manifest file exists in the current directory.
final FlutterManifest? _projectManifest;

➜  ~ flutter --version
Flutter 3.35.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 05db968908 (5 weeks ago) • 2025-08-25 10:21:35 -0700
Engine • hash abb725c9a5211af2a862b83f74b7eaf2652db083 (revision a8bfdfc394) (1 months ago) • 2025-08-22 23:51:12.000Z
Tools • Dart 3.9.0 • DevTools 2.48.0

Activity

  1. changed the title [-]Flutter CLI ignores pubspec's config if current dir is not app's root.[/-] [+]Flutter CLI ignores pubspec's SwiftPM enabled config if current dir is not app's root.[/+] on Oct 1, 2025
  2. changed the title [-]Flutter CLI ignores pubspec's SwiftPM enabled config if current dir is not app's root.[/-] [+]Flutter CLI ignores pubspec's SwiftPM enabled config if current dir is not app's root[/+] on Oct 1, 2025
  3. darshankawar commented on Oct 1, 2025

    @darshankawar
    Member

    Thanks for the detailed report. Upon following the steps, I see below in podfile.lock:

    Image

    Keeping the issue open and labeing for team's tracking.

  4. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    team-toolOwned by Flutter Tool team
    platform-iosiOS applications specifically
    and removed
    in triagePresently being triaged by the triage team
    on Oct 1, 2025
  5. added
    team-iosOwned by iOS platform team
    and removed
    team-toolOwned by Flutter Tool team
    on Oct 6, 2025
  6. vashworth commented on Oct 16, 2025

    @vashworth
    Contributor

    From triage: So this issue is not specific to SwiftPM. Any flutter feature enabled/disabled through the config will run into this problem.

    Basically, if you're not in the root project directory, Flutter will attempt to change the working directory to the root project directory:

    // If there is no pubspec in the current directory, look in the parent
    // until one can be found.
    final String? path = findProjectRoot(globals.fs, globals.fs.currentDirectory.path);
    if (path == null) {
    throwToolExit(globals.userMessages.flutterNoPubspec);
    }
    if (path != globals.fs.currentDirectory.path) {
    globals.fs.currentDirectory = path;
    globals.printStatus(
    'Changing current working directory to: ${globals.fs.currentDirectory.path}',
    );
    }
    }

    Flutter features uses the FlutterManifest (pubspec):

    bool? _isEnabledAtProjectLevel(String featureName) {
    final Object? configSection = _projectManifest?.flutterDescriptor['config'];
    if (configSection == null) {
    return null;
    }
    if (configSection is! Map) {
    throwToolExit(
    'The "config" property of "flutter" in pubspec.yaml must be a map, but '
    'got $configSection (${configSection.runtimeType})',
    );
    }
    return _requireBoolOrNull(
    configSection[featureName],
    featureName: featureName,
    source: '"flutter: config:" in pubspec.yaml',
    );
    }

    However, the manifest is defined in the context_runner, which I think happens before the currentDirectory gets swapped. So therefore, does not use:

    FeatureFlags: () => FlutterFeatureFlags(
    flutterVersion: globals.flutterVersion,
    featuresConfig: FlutterFeaturesConfig(
    globalConfig: globals.config,
    platform: globals.platform,
    projectManifest: FlutterManifest.createFromPath(
    globals.fs.path.join(globals.fs.currentDirectory.path, 'pubspec.yaml'),
    fileSystem: globals.fs,
    logger: globals.logger,
    ),
    ),
    platform: globals.platform,
    ),

  7. added
    team-toolOwned by Flutter Tool team
    and removed
    team-iosOwned by iOS platform team
    on Oct 16, 2025
  8. changed the title [-]Flutter CLI ignores pubspec's SwiftPM enabled config if current dir is not app's root[/-] [+]Flutter CLI ignores pubspec's Flutter features config (like SwiftPM) if current dir is not app's root[/+] on Oct 16, 2025
  9. added
    P2Important issues not at the top of the work list
    triaged-iosTriaged by iOS platform team
    on Oct 16, 2025
  10. flutter-triage-bot commented on Oct 16, 2025

    @flutter-triage-bot

    The triaged-ios label is irrelevant if there is no team-ios label or fyi-ios label.

  11. removed
    P2Important issues not at the top of the work list
    on Oct 28, 2025
  12. added
    P2Important issues not at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Nov 11, 2025
  13. added a commit that references this issue on Jan 8, 2026
    e30750c
  14. Albert221 commented on Jan 12, 2026

    @Albert221
    ContributorAuthor

    @bkonyi I've submitted a PR for this at #180689 FYI :)

  15. added a commit that references this issue on Jan 23, 2026
    eba55c7
  16. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jan 27, 2026
  17. github-actions commented on Feb 10, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  18. locked as resolved and limited conversation to collaborators on Feb 10, 2026
  19. added a commit that references this issue on Feb 10, 2026
    777d377
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listr: fixedIssue is closed as already fixed in a newer versionteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions