Plugin fails in Xcode Cloud: "You don’t have permission to save the file “Strings.swift” in the folder “SwiftGenPlugin”
Running the Swiftgen plugin in an Xcode Cloud build fails with the following errors:
Plug-in ended with non-zero exit code: 64) xcodebuild: error: Failed to copy build products to test products file with error: The file “Products” couldn’t be opened because there is no such file. It seems like there was an error running SwiftGen. Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “Strings.swift” in the folder “SwiftGenPlugin”." UserInfo={NSURL=file:///Volumes/workspace/DerivedData/SourcePackages/plugins/assets.output/Assets/SwiftGenPlugin/Strings.swift, NSUserStringVariant=Folder, NSUnderlyingError=0x6000036c5ce0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
The Package.swift for our "Assets" Package looks like this:
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "Assets",
defaultLocalization: "de",
platforms: [.iOS(.v17)],
products: [
.library(name: "Assets", targets: ["Assets"]),
],
dependencies: [
.package(url: "https://github.com/chrs1885/WCAG-Colors.git", from: "1.0.0"),
.package(url: "https://github.com/SwiftGen/SwiftGenPlugin", from: "6.6.0")
],
targets: [
.target(
name: "Assets",
dependencies: ["WCAG-Colors"],
path: "Sources",
resources: [.copy("Resources/dummy.txt")],
plugins: [
.plugin(name: "SwiftGenPlugin", package: "SwiftGenPlugin")
]
),
]
)
and swiftgen.yml is
xcassets:
inputs: Sources/Resources/Assets.xcassets
outputs:
templateName: swift5
output: ${DERIVED_SOURCES_DIR}/Assets.swift
params:
publicAccess: true
strings:
inputs: Sources/Resources/de.lproj/Localizable.strings
outputs:
templateName: structured-swift5
output: ${DERIVED_SOURCES_DIR}/Strings.swift
params:
publicAccess: true
(Possibly related to #12 and/or #13?)
I am also facing this issue.
Did you find any solution to this issue?
For the time being, we've reverted to run swiftgen locally (in a run phase and using kicker) and committing the generated files to git.
It seems to be a bug in SPM + Xcode Cloud, the fix seems to be implemented but not released yet https://github.com/apple/swift-package-manager/issues/6948
I tried to fix it with a quick fix, available in my private fork
The actual fix is in SwiftGen https://github.com/SwiftGen/SwiftGen/pull/1102
Then I made a private release of a new binary version of SwiftGen CLI version 6.6.2+deriveddatafix (https://github.com/shadone/SwiftGen/releases/tag/6.6.2%2Bderiveddatafix)
And then there is a fork of SwiftGenPlugin to use that new version of SwiftGen CLI tool in a branch https://github.com/shadone/SwiftGenPlugin/tree/6.6.2%2Bderiveddatafix
This makes SwiftGenPlugin work for me in Xcode Cloud:
dependencies: [
.package(url: "https://github.com/shadone/SwiftGenPlugin", branch: "6.6.2+deriveddatafix"),