Skip to content

No way to resolve name collisions with SwiftPM with Flutter #148424

@vashworth

Description

@vashworth

Steps to reproduce

  1. flutter config --enable-swift-package-manager
  2. flutter create --template=plugin --platforms=ios plugin_one
  3. Create file plugin_one/ios/plugin_one/Sources/same_name/File.swift
  4. In plugin_one/ios/plugin_one/Package.swift, add the following
targets: [
        .target(
            name: "plugin_one",
            dependencies: [
+                "same_name",
            ],
            resources: [
                .process("Resources"),
            ]
        ),
+        .target(
+            name: "same_name",
+            dependencies: []
+        )
    ]
  1. flutter create --template=plugin --platforms=ios plugin_two
  2. Create file plugin_two/ios/plugin_two/Sources/same_name/File.swift
  3. In plugin_two/ios/plugin_two/Package.swift, add the following
targets: [
        .target(
            name: "plugin_two",
            dependencies: [
+                "same_name",
            ],
            resources: [
                .process("Resources"),
            ]
        ),
+        .target(
+            name: "same_name",
+            dependencies: []
+        )
    ]
  1. In plugin_two/example/pubspec.yaml, add a dependency on plugin_one
dependencies:
  flutter:
    sdk: flutter

  plugin_two:
    # When depending on this package from a real application you should use:
    #   plugin_two: ^x.y.z
    # See https://dart.dev/tools/pub/dependencies#version-constraints
    # The example app is bundled with the plugin so we use a path dependency on
    # the parent directory to use the current plugin's version.
    path: ../
+  plugin_one:
+    path: [insert path to plugin_one]
  1. In plugin_two/example, run flutter build ios --no-codesign

Actual results

This results in error:

Unable to get Xcode project information:
 2024-05-15 15:26:42.700 xcodebuild[26094:19473636] Writing error result bundle to
 /var/folders/xw/ky8z400d5ys67zy99pr42lyw011smf/T/ResultBundle_2024-15-05_15-26-0042.xcresult
xcodebuild: error: Could not resolve package dependencies:
  multiple targets named 'same_name' in: 'plugin_one', 'plugin_two'; consider using the `moduleAliases` parameter in manifest to
  provide unique names

Logs

Logs
<!-- Paste your logs here -->

Flutter Doctor output

Doctor output
<!-- Paste your output here -->

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listplatform-iosiOS applications specificallyplatform-macBuilding on or for macOS specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions