Xcode 12.5 on MBP with M1 fails resolving package dependency with .systemLibrary target. Running Xcode without Rosseta.
The project is setup with 2 spm packages. Both of them added to the project .xcworkspace and only one of them linked within the app. Both packages are local dependencies. A
package has B
package as dependency and B
package has libgit2
as .systemLibrary dependency. Then, if I open the project, Xcode can't find pkg-config and then not resolves libgit2 dependency.
This doesn't happens if I generate the A pbxproj
with swift package generate-xcodeproj
, in this case, the project resolves fine and I can build it without any problem.
The A Package.swift
is:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "A",
platforms: [
.macOS(.v11)
],
products: [
.library(
name: "A",
targets: ["A"]
),
],
dependencies: [
.package(path: "../B")
],
targets: [
.target(
name: "A",
dependencies: ["B"]
),
.testTarget(
name: "ATests",
dependencies: ["A"]
),
]
)
The B Package.swift
is:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "B",
platforms: [
.macOS(.v11)
],
products: [
.library(
name: "B",
targets: ["B"]
)
],
dependencies: [],
targets: [
.systemLibrary(
name: "Clibgit2",
pkgConfig: "libgit2",
providers: [
.brew(["libgit2"])
]
),
.target(
name: "B",
dependencies: [
.target(name: "Clibgit2")
]
),
.testTarget(
name: "BTests",
dependencies: ["B"]
)
]
)
The Clibgit2
target is well configured with the module.modulemap
and shim.h
files.
I checked pkg-config
is installed and has the libgit2 package info with pkg-config --list
Also I opened the project on an intel mac and is working fine.
libgit2 is installed by brew.