1

I have a Swift project which has a dependency on Apple's Swift Collections package. I've added the package to the project and everything works fine when building from Xcode (for both Debug and Release).

But when I try to build from the command line with xcodebuild, the build fails with an error:

/Users/Robert/XCode/Solitaire-Solver/Solitaire-Solver/Moves.swift:9:8: error: no such module 'Collections'
import Collections
       ^

** BUILD FAILED **

The following build commands failed:
  CompileSwift normal arm64 (in target 'Solitaire-Solver' from project 'Solitaire-Solver')
  CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'Solitaire-Solver' from project 'Solitaire-Solver')

At the start of the build, xcodebuild outputs the following, so it appears to be finding the dependency fine.

Resolved source packages:
swift-collections: https://github.com/apple/swift-collections.git @ 1.0.2`

Any ideas on what is failing and how to resolve it? I am on Version 13.2.1 of Xcode.

closetCoder
  • 1,064
  • 10
  • 21
  • I'm sure you've solved this by now, but could the command-line version be defaulting to a target that doesn't have the Collections package added to it? – NRitH Feb 02 '22 at 16:31

0 Answers0