Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin fails in Xcode Cloud: "You don’t have permission to save the file “Strings.swift” in the folder “SwiftGenPlugin” #18

Open
gereons opened this issue Nov 6, 2023 · 5 comments · May be fixed by SwiftGen/SwiftGen#1102

Comments

@gereons
Copy link

gereons commented Nov 6, 2023

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?)

@parvez-keeptruckin
Copy link

I am also facing this issue.

@akankshakitman
Copy link

Did you find any solution to this issue?

@gereons
Copy link
Author

gereons commented Jan 3, 2024

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.

@shadone
Copy link

shadone commented Jan 16, 2024

It seems to be a bug in SPM + Xcode Cloud, the fix seems to be implemented but not released yet apple/swift-package-manager#6948

@shadone
Copy link

shadone commented Jan 16, 2024

I tried to fix it with a quick fix, available in my private fork

The actual fix is in SwiftGen SwiftGen/SwiftGen#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"),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants