apple / swift-openapi-generator

Generate Swift client and server code from an OpenAPI document.
https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
Apache License 2.0
1.23k stars 89 forks source link

Disable use of auxiliary file to prevent permission error on XcodeCloud #519

Closed novr closed 4 months ago

novr commented 4 months ago

Motivation

Modifications

The implementation of swift-openapi-generator is try encoder.encode(container).write(to: url, atomically: true, encoding: .utf8). if atomically is true, the content is written to an intermediate file and then moved to the outputURL. However, XocdeCloud does not seem to allow writing outside of the pluginWorkDirectory, even for temporary files created by the Foundation framework.

The easiest way to get Build to succeed on Xcode Cloud seems to be to change "atomically" to false.

What do you think about this change?

Result

Swift Package Manager's Build Tools plug-in works on XcodeCloud

Test Plan

N/A

simonjbeaumont commented 4 months ago

Interesting. Are you saying that, with this patch, you no longer need the defaults-write workaround detailed here: https://developer.apple.com/forums/thread/732893?

czechboy0 commented 4 months ago

I'm a bit confused, this codepath is only hit when --diagnostics-output-path is passed, but I don't think we pass that when invoking the CLI from the plugin. Are you sure this fixes it, @novr?

novr commented 4 months ago

@czechboy0 Sorry, this method didn't solve the problem.

simonjbeaumont commented 4 months ago

No problem, thanks for taking the time to investigate @novr! Hopefully the defaults-write workaround detailed in the other issue will allow you to make use of Xcode Cloud, if that's your goal.