SwiftGenPlugin: Plugin doesn't work with Xcode 15
I tried to build my project with Xcode 15 and got a new error:
Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “Strings+Generated.swift” in the folder “Generated”." UserInfo={NSFilePath=ticketchain/Supporting Files/Generated/Strings+Generated.swift, NSUnderlyingError=0x6000023308a0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
Does anyone know how to fix it ?
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 37
- Comments: 18
Commits related to this issue
- Swift from swiftgen SPM plugin to build phases scripts Unfortunatelly swiftgen SPM plugin has multiple issues with Xcode 15. For now swiftgen execution must be switched to the build phase scripts. I... — committed to Chlup/secant-ios-wallet by Chlup 3 years ago
- Swift from swiftgen SPM plugin to build phases scripts Unfortunatelly swiftgen SPM plugin has multiple issues with Xcode 15. For now swiftgen execution must be switched to the build phase scripts. I... — committed to LukasKorba/secant-ios-wallet by Chlup 3 years ago
- fix(build): fix SwiftGenPlugin error on Xcode 15 @see https://github.com/SwiftGen/SwiftGenPlugin/issues/14#issuecomment-1727696732 — committed to nmotod/nefoli-ios by nmotod 3 years ago
- fix(build): fix SwiftGenPlugin error on Xcode 15 @see https://github.com/SwiftGen/SwiftGenPlugin/issues/14#issuecomment-1727696732 — committed to nmotod/nefoli-ios by nmotod 3 years ago
- fix(build): fix SwiftGenPlugin error on Xcode 15 @see https://github.com/SwiftGen/SwiftGenPlugin/issues/14#issuecomment-1727696732 — committed to nmotod/nefoli-ios by nmotod 3 years ago
[Update] Got it sorted out and works with current SwiftGenPlugin! 😃
Plugin already provides environment variables one of which is
DERIVED_SOURCES_DIR. SwiftGen tool itself allows for environment variable usage - that means we can easily use such env variable in config. Below is example swiftgen.yml config working with Xcode 15:See that output uses
${DERIVED_SOURCES_DIR}env variable which is expanded by swiftgne during run, see docs: https://github.com/SwiftGen/SwiftGen/blob/6.6.2/Documentation/ConfigFile.md#environment-variablesOne downside (at least for me) is that now it works, but won’t create file that can be checked in to the repository. That is little bit sad, because it allowed me to see what is changing while eg manipulating localisable strings. At the same time pros is that no-one will ever again try to manipulate that by hand… 🗡️
[Update2]: All of that is mentioned in the plugin documentation… https://github.com/SwiftGen/SwiftGenPlugin#add-a-swiftgen-config Solving the issue for few hours saved me 15 minutes of reading documentation 🤦♂️
The upstream feedback: “If this works on Xcode 14, it was just a bug and Xcode 15 fixed it.”
https://github.com/apple/swift-package-manager/issues/6814
And we may consider using
SwiftGen-Generateto replace such usage. (buildToolcan’t havewriteToPackageDirectorypermission currently.)However there is other issue with
SwiftGen-Generateand the fix PR(#9) is still open.As a temporary solution until the update comes in, you can use this functionality https://github.com/SwiftGen/SwiftGenPlugin#using-it-as-a-command to bypass the access rights error.
Does it work for you with standard
DerivedDatadirectory? I noticed that swiftgen will also fail if you would try to have nests folder structure for generated files. Eg those should lie flat in theDERIVED_SOURCES_DIRor otherwise folder cannot be created. If it still fails then I suppose that is SPM issue and good one to create issue on their side.I have mistakenly created similar issue but in SwiftGen cli repo: https://github.com/SwiftGen/SwiftGen/issues/1075 Generally this is also issue for me in my current project. Command workaround is not best solution since in my case we are using SwiftGen plugin inside other Swift Package.