I have two packages, Foo
and Bar
. Both are in the same directory:
.
├─ Bar/
│ ├─ Sources/
│ │ └─ Bar/
│ │ └─ Bar.swift
│ ├─ Tests/
│ │ └─ BarTests/
│ │ └─ BarTests.swift
│ └─ Package.swift
└─ Foo/
├─ Sources/
│ └─ Foo/
│ └─ Foo.swift
├─ Tests/
│ └─ FooTests/
│ └─ FooTests.swift
└─ Package.swift
Both define two targets; a library and tests:
// swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "Foo",
products: [
.library(name: "Foo", targets: ["Foo"])
],
dependencies: [
.package(url: "../Bar", .branch("master"))
],
targets: [
.target(name: "Foo", dependencies: []),
.testTarget(name: "FooTests", dependencies: ["Bar"])
]
)
// swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "Bar",
products: [
.library(name: "Bar", targets: ["Bar"])
],
dependencies: [
.package(url: "../Foo", .branch("master"))
],
targets: [
.target(name: "Bar", dependencies: ["Foo"]),
.testTarget(name: "BarTests", dependencies: ["Bar"])
]
)
Running swift build
, swift package
or any of its variants on either package will cause it to segfault:
$ cd Foo
$ swift build
Updating /Absolute/Path/To/Bar
[1] 10067 segmentation fault swift build
There's a circular dependency between the packages, but I was hoping we'd be safe since there are no circular dependencies between any of the targets:
┌─ FooTests
Foo ── Bar ─┤
└─ BarTests
Is this currently possible without creating a third package containing shared code? Note that it should also work when both are in separate remote repositories.