`swift run xcodegen` fails
417-72KI opened this issue · comments
Takuhiro Muta commented
I'm using XcodeGen as a package dependency like
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Tools",
platforms: [.macOS(.v12)],
products: [],
dependencies: [
.package(url: "https://github.com/yonaskolb/XcodeGen", from: "2.38.0"),
],
targets: []
)
and run by a command like
xcrun --sdk macosx swift run --package-path Tools xcodegen
Recently, running this command fails by compile error.
/path/to/project/.build/checkouts/XcodeGen/Sources/XcodeGenKit/PBXProjGenerator.swift:313:20: error: cannot assign to property: 'packages' is a get-only property
pbxProject.packages = packageReferences.sorted { $0.key < $1.key }.map { $1 }
~~~~~~~~~~~^~~~~~~~
[269/272] Compiling XcodeGenKit InfoPlistGenerator.swift
/path/to/project/.build/checkouts/XcodeGen/Sources/XcodeGenKit/PBXProjGenerator.swift:313:20: error: cannot assign to property: 'packages' is a get-only property
pbxProject.packages = packageReferences.sorted { $0.key < $1.key }.map { $1 }
~~~~~~~~~~~^~~~~~~~
[270/272] Compiling XcodeGenKit PBXProjGenerator.swift
/path/to/project/.build/checkouts/XcodeGen/Sources/XcodeGenKit/PBXProjGenerator.swift:313:20: error: cannot assign to property: 'packages' is a get-only property
pbxProject.packages = packageReferences.sorted { $0.key < $1.key }.map { $1 }
~~~~~~~~~~~^~~~~~~~
[271/272] Compiling XcodeGenKit ProjectGenerator.swift
/path/to/project/.build/checkouts/XcodeGen/Sources/XcodeGenKit/PBXProjGenerator.swift:313:20: error: cannot assign to property: 'packages' is a get-only property
pbxProject.packages = packageReferences.sorted { $0.key < $1.key }.map { $1 }
~~~~~~~~~~~^~~~~~~~
It seems to be something changed in PBXProject
class.
Yonas Kolb commented
This seems to be because XcodeProj introduced a breaking change in a minor release tuist/XcodeProj#799
Packages used as dependencies don't use their Package.resolved
, so XcodeProj updated to that version. You can fix it locally by including XcodeProj as a dependency with version 8.13.0.
We should fix this locally by updating and resolving the issue, but then making the version exact
so this doesn't happen again in the future.