pointfreeco / swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
https://www.pointfree.co/collections/composable-architecture
MIT License
12.22k stars 1.42k forks source link

`swift-navigation` and `swiftui-navigation` conflict #3273

Closed alephao closed 1 month ago

alephao commented 1 month ago

Description

swift-navigation 2.0 was released a few days ago and will replace swiftui-navigation. I tried adding the swift-navigation package to my project and got the following error message from spm:

error: multiple targets named 'SwiftUINavigation' in: 'swift-navigation', 'swiftui-navigation'

Checklist

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

  1. Create a new package swift package init
  2. Add the dependencies:
    dependencies: [
    .package(url: "https://github.com/pointfreeco/swift-composable-architecture", from: "1.12.0"),
    .package(url: "https://github.com/pointfreeco/swift-navigation", from: "2.0.0"),
    ],
  3. Run swift build

The Composable Architecture version information

No response

Destination operating system

No response

Xcode version information

No response

Swift Compiler version information

Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
mbrandonw commented 1 month ago

Hi @alephao, typically you can fix this using moduleAliases in SPM. This allows you to disambiguate SwiftUINavigation that comes from swift-navigation version swiftui-navigation.

So, if you update one of your target's dependencies to do something like this:

.target(
  name: "MyTarget",
  dependencies: [
    .product(
      name: "SwiftUINavigation", 
      package: "swift-navigation", 
      moduleAliases: ["SwiftUINavigation", "SwiftUINavigation"]
    )
  ]
)

…it should work.

However, it also turns out that Xcode's support for moduleAliases is completely busted, even though it works in SPM just fine.

We have a PR that will merge soon (#3180) that integrates the new swift-navigation library into TCA, and so then at that point you will not need to depend on both libraries. And unfortunately I think until then you just can't use swift-navigation with TCA due to Xcode bugs.

Since this isn't any issue with the library I am going to convert it to a discussion. Feel free to continue the conversation over there.