Skip to content

Flags --explicit-package-dependencies and --enable-swift-package-manager collide #163272

Description

@matanlurey

You can reproduce this in the swift_package_manager_test.dart integration test.

First, opt-in to --explicit-package-dependencies:

flutter config --explicit-package-dependencies

Then, run the integration test. All of the tests fail, so just picking one is quite a bit faster to iterate on:

$ cd packages/tools
$ dart test test/integration.shard/swift_package_manager_test.dart -n "Swift Package Manager integration for ios with objc"

...

  stderr: 
  [  +15 ms] Parse Issue (Xcode): Module 'ios_objc_cocoapods_plugin' not found
             /var/folders/qw/qw_3qd1x4kz5w975jhdq4k58007b7h/T/swift_package_manager_enabled.1xqwz9/ios_objc_spm_app/ios/Runner/GeneratedPluginRegistrant.m:17:8

GeneratedPluginRegistrant.m looks like this:

//
//  Generated file. Do not edit.
//

// clang-format off

#import "GeneratedPluginRegistrant.h"

#if __has_include(<integration_test/IntegrationTestPlugin.h>)
#import <integration_test/IntegrationTestPlugin.h>
#else
@import integration_test;
#endif

#if __has_include(<ios_objc_cocoapods_plugin/IosObjcCocoapodsPlugin.h>)
#import <ios_objc_cocoapods_plugin/IosObjcCocoapodsPlugin.h>
#else
@import ios_objc_cocoapods_plugin;
#endif

@implementation GeneratedPluginRegistrant

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
  [IntegrationTestPlugin registerWithRegistrar:[registry registrarForPlugin:@"IntegrationTestPlugin"]];
  [IosObjcCocoapodsPlugin registerWithRegistrar:[registry registrarForPlugin:@"IosObjcCocoapodsPlugin"]];
}

@end

In the test project, there are no dev-only dependencies:

# pubspec.yaml

dependencies:
  ios_objc_cocoapods_plugin:
    path: /var/folders/qw/qw_3qd1x4kz5w975jhdq4k58007b7h/T/swift_package_manager_enabled.1xqwz9/ios_objc_cocoapods_plugin
  integration_test:
    path: /Users/matanl/Developer/flutter/packages/integration_test

And indeed, none of them are detected as dev:

# .flutter-plugins-dependencies

{
  "info": "This is a generated file; do not edit or check into version control.",
  "plugins": {
    "ios": [
      {
        "name": "integration_test",
        "path": "/Users/matanl/Developer/flutter/packages/integration_test/",
        "native_build": true,
        "dependencies": [],
        "dev_dependency": false
      },
      {
        "name": "ios_objc_cocoapods_plugin",
        "path": "/var/folders/qw/qw_3qd1x4kz5w975jhdq4k58007b7h/T/swift_package_manager_enabled.1xqwz9/ios_objc_cocoapods_plugin/",
        "native_build": true,
        "dependencies": [],
        "dev_dependency": false
      }
    ],
    "android": [
      {
        "name": "integration_test",
        "path": "/Users/matanl/Developer/flutter/packages/integration_test/",
        "native_build": true,
        "dependencies": [],
        "dev_dependency": false
      }
    ],
    "macos": [],
    "linux": [],
    "windows": [],
    "web": []
  },
  "dependencyGraph": [
    {
      "name": "integration_test",
      "dependencies": []
    },
    {
      "name": "ios_objc_cocoapods_plugin",
      "dependencies": []
    }
  ],
  "date_created": "2025-02-13 16:08:11.766458",
  "version": "3.30.0-1.0.pre.163",
  "swift_package_manager_enabled": {
    "ios": true,
    "macos": false
  }
}

Activity

  1. added
    c: regressionIt was better in the past than it is now
    fyi-iosFor the attention of iOS platform team
    P1High-priority issues at the top of the work list
    team-toolOwned by Flutter Tool team
    on Feb 14, 2025
  2. self-assigned this
    on Feb 14, 2025
  3. matanlurey commented on Feb 14, 2025

    @matanlurey
    ContributorAuthor

    For whatever reason, opting-out, building, and opting back in succeeds:

    flutter config --no-explicit-package-dependencies
    flutter build ios
    flutter config --explicit-package-dependencies

    This holds even if you use flutter clean, so I'm pretty baffled; it is likely something to do with the exact workflow in the test:

    // Rebuild app with Swift Package Manager enabled, migrating the app and using the Swift Package Manager version of
    // integration_test.
    await SwiftPackageManagerUtils.enableSwiftPackageManager(
    flutterBin,
    workingDirectoryPath,
    );
    await SwiftPackageManagerUtils.buildApp(

    // Build an app using both a CocoaPods and Swift Package Manager plugin.
    SwiftPackageManagerUtils.addDependency(
    appDirectoryPath: appDirectoryPath,
    plugin: createdCocoaPodsPlugin,
    );
    await SwiftPackageManagerUtils.buildApp(
    flutterBin,

  4. matanlurey commented on Feb 14, 2025

    @matanlurey
    ContributorAuthor

    I managed to narrow it down to generateLegacyPlugins, which is always false with --explicit-package-depednencies:

    generateLegacyPlugins ??= !featureFlags.isExplicitPackageDependenciesEnabled;

    That makes me believe something in iOS land is trying to read or relies on the existence of the .flutter-plugins file, which is not something we thought was true. That also makes me think #162399 is caused by a workaround we added for this particular flag:

    https://github.com/flutter/flutter/blob/main/packages/flutter_tools/lib/src/macos/cocoapod_utils.dart#L51

  5. github-actions commented on Mar 4, 2025

    @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.

  6. locked as resolved and limited conversation to collaborators on Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: regressionIt was better in the past than it is nowfyi-iosFor the attention of iOS platform teamteam-toolOwned by Flutter Tool team

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions