-
Notifications
You must be signed in to change notification settings - Fork 109
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
fix deprecation warning for Plugin's Path #363
Conversation
@swift-server-bot test this please |
#if canImport(FoundationEssentials) | ||
import FoundationEssentials | ||
#else | ||
import struct Foundation.URL | ||
import class Foundation.ProcessInfo | ||
import class Foundation.FileManager | ||
import struct Foundation.ObjCBool | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid we need full Foundation here. This is a built time dependency. So therefore we don't really care.
#if canImport(FoundationEssentials) | |
import FoundationEssentials | |
#else | |
import struct Foundation.URL | |
import class Foundation.ProcessInfo | |
import class Foundation.FileManager | |
import struct Foundation.ObjCBool | |
#endif | |
import Foundation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct - just realized that when testing the CI compilation (that failed) - I just pushed a change
// this shared global variable is safe because we're mutating it in a dispatch group | ||
// https://developer.apple.com/documentation/foundation/process/1408746-terminationhandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment here is misleading. The important thing here is the following. We write to the variable from a single SerialDispatchQueue here. We wait until the process is run below process.waitUntilExit()
. This means no further writes to output
will happen. This makes it save for us to read the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should switch to the new Foundation Process API as soon as it is available:
https://github.com/apple/swift-foundation/blob/main/Proposals/0007-swift-subprocess.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to
// We need to use an unsafe transfer here to get the fd into our Sendable closure.
// This transfer is fine, because we write to the variable from a single SerialDispatchQueue here.
// We wait until the process is run below process.waitUntilExit().
// This means no further writes to output will happen.
// This makes it save for us to read the output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #364 to keep track of SubProcess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much! This is so great!
Replace the usage of Plugin's
Path
withURL
Motivation:
Path
is deprecated in Swift 6Modifications:
Path
withURL
and adjust path components management accordinglyResult:
no more compilation warnings when compiling the
archive
plugin on Swift 6Command to test the plugin with Swift 6