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.19k stars 1.42k forks source link

iOS 16 packages have dependency conflict warning when importing Composable #3255

Closed krze closed 1 month ago

krze commented 1 month ago

Description

When you have a project with a package added to it which supports iOS/tvOS 16, then add Swift Composable Architecture as a dependency, the resolve dependencies step will display a warning about conflicting dependencies regarding swift-syntax between the swift-composable-architecture package and its dependencies. This is because the Swift 5.9 package version of Composable uses the swift-syntax package from "https://github.com/apple/swift-syntax" instead of "https://github.com/swiftlang/swift-syntax" like its dependencies.

Checklist

Expected behavior

No warnings appear

Actual behavior

Several warnings appear when resolving package dependencies:

➜  Test-Package-App git:(main) ✗ xcodebuild -resolvePackageDependencies
Command line invocation:
    /Applications/Xcode-15.3.0.app/Contents/Developer/usr/bin/xcodebuild -resolvePackageDependencies

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Resolve Package Graph

Updating from https://github.com/pointfreeco/swiftui-navigation

Updating from https://github.com/pointfreeco/swift-composable-architecture.git

Updating from https://github.com/pointfreeco/swift-identified-collections

Updating from https://github.com/pointfreeco/xctest-dynamic-overlay

Updating from https://github.com/pointfreeco/swift-clocks

Updating from https://github.com/pointfreeco/combine-schedulers

Updating from https://github.com/pointfreeco/swift-issue-reporting

Updating from https://github.com/apple/swift-collections

Updating from https://github.com/pointfreeco/swift-case-paths

Updating from https://github.com/pointfreeco/swift-dependencies

Updating from https://github.com/pointfreeco/swift-perception

Updating from https://github.com/pointfreeco/swift-custom-dump

Updating from https://github.com/apple/swift-syntax

Updating from https://github.com/pointfreeco/swift-concurrency-extras

'swift-case-paths' dependency on 'https://github.com/swiftlang/swift-syntax' conflicts with dependency on 'https://github.com/apple/swift-syntax' which has the same identity 'swift-syntax'. this will be escalated to an error in future versions of SwiftPM.

'swift-dependencies' dependency on 'https://github.com/swiftlang/swift-syntax' conflicts with dependency on 'https://github.com/apple/swift-syntax' which has the same identity 'swift-syntax'. this will be escalated to an error in future versions of SwiftPM.

'swift-perception' dependency on 'https://github.com/swiftlang/swift-syntax' conflicts with dependency on 'https://github.com/apple/swift-syntax' which has the same identity 'swift-syntax'. this will be escalated to an error in future versions of SwiftPM.

multiple similar targets 'IssueReporting', 'IssueReportingTestSupport', 'XCTestDynamicOverlay' appear in package 'swift-issue-reporting' and 'xctest-dynamic-overlay', this may indicate that the two packages are the same and can be de-duplicated by using mirrors. if they are not duplicate consider using the `moduleAliases` parameter in manifest to provide unique names

Resolved source packages:
  swift-identified-collections: https://github.com/pointfreeco/swift-identified-collections @ 1.1.0
  xctest-dynamic-overlay: https://github.com/pointfreeco/xctest-dynamic-overlay @ 1.2.2
  xctest-dynamic-overlay: https://github.com/pointfreeco/swift-issue-reporting @ 1.2.2
  swift-perception: https://github.com/pointfreeco/swift-perception @ 1.3.3
  TestImportPackage: /Users/kenneth.krzeminski/dev/TestImportPackage
  swift-concurrency-extras: https://github.com/pointfreeco/swift-concurrency-extras @ 1.1.0
  combine-schedulers: https://github.com/pointfreeco/combine-schedulers @ 1.0.1
  swift-composable-architecture: https://github.com/pointfreeco/swift-composable-architecture.git @ 1.11.2
  swift-syntax: https://github.com/apple/swift-syntax @ 600.0.0-prerelease-2024-06-12
  swift-custom-dump: https://github.com/pointfreeco/swift-custom-dump @ 1.3.1
  swift-dependencies: https://github.com/pointfreeco/swift-dependencies @ 1.3.4
  swift-case-paths: https://github.com/pointfreeco/swift-case-paths @ 1.5.3
  swift-clocks: https://github.com/pointfreeco/swift-clocks @ 1.0.3
  swiftui-navigation: https://github.com/pointfreeco/swiftui-navigation @ 1.5.2
  swift-collections: https://github.com/apple/swift-collections @ 1.1.2

2024-07-24 12:38:04.047 xcodebuild[14219:2732218] Writing error result bundle to /var/folders/tr/1ww2xbr96s7998h4wpq3d1t00000gp/T/ResultBundle_2024-24-07_12-38-0004.xcresult
xcodebuild: error: Could not resolve package dependencies:
  multiple similar targets 'IssueReporting', 'IssueReportingTestSupport', 'XCTestDynamicOverlay' appear in package 'swift-issue-reporting' and 'xctest-dynamic-overlay', this may indicate that the two packages are the same and can be de-duplicated by using mirrors. if they are not duplicate consider using the `moduleAliases` parameter in manifest to provide unique names

Steps to reproduce

  1. Create a new xcode project
  2. Create a package within the project, then add it to the project
  3. Add swift-composable-architecture as a dependency to the package and ensure at least one target in the package depends on it (I used 1.11.2)
  4. Compile the app, or run xcodebuild -resolvePackageDependencies from the project directory
  5. Observe warnings

The Composable Architecture version information

1.11.2

Destination operating system

iOS 16

Xcode version information

15.3

Swift Compiler version information

➜  Test-Package-App git:(main) ✗ xcrun swiftc --version
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

Sample app: Sample.zip

funkyboy commented 1 month ago

I have the same error using different versions:

Xcode 15.0.1 Destination operating system: iOS 17 Composable Architecture: 1.4.2

Maybe this is due to the renaming of the XCTestDynamicOverlay repo?

When I add swift-composable-architecture in Xcode I get:

Screenshot 2024-07-24 at 19 04 46

If I click "Add Anyway" then I can't even compile the app.

Sample app TestApp.zip

stephencelis commented 1 month ago

Thanks for the example! We were able to reproduce and determine that SwiftPM does not resolve the dependency rename in Xcode while it does work in other contexts. We believe this should be fixed with a pinned TCA as long as you update any other previously conflicting dependency to its latest version.

funkyboy commented 1 month ago

I had to run xcodebuild -resolvePackageDependencies to fix it. Selecting "Update to Latest Package Versions" in Xcode didn't work 🤷.

There's still some warnings but at least I can now compile and go on.

Screenshot 2024-07-25 at 10 06 47

Thanks for the quick fix!

krze commented 1 month ago

Hi @stephencelis, I pinned TCA in Package.resolved and it did not resolve the warnings. I've attached the changes to the example app to demonstrate the issue. Note the added Package.resolved in the package with the pin. Sample 2.zip

mbrandonw commented 1 month ago

Hi @krze, if you update the packages to their latest version (TCA can stay at 1.11.2) it should work:

image
mbrandonw commented 1 month ago

I think this issue has now been fixed so I am going to close this out. Please feel free to open a discussion if you have more questions!

krze commented 1 month ago

Confirmed, this is fixed. Thank you!