According to the announcement in the forums, FileHandle should be part of FoundationEssentials. But currently it isn't. I know the new Foundation might still be a bit incomplete, but since a file handle seems to an essential (sic!) part of Foundation, I am wondering if it might have been replaced by something else, and if yes, is there a kind of list for replacements like that or for parts that are still missing? Do I have to import the full Foundation for now the get FileHandle?
I just hit this in Swift 6.3. Is there any lightweight replacement for FileHandle that I can use for now?
Would FileDescriptor work in your case?
Looks like it should work. However, my code also supports macOS, so should I use SystemPackage for both macOS and Linux, or use System on macOS and SystemPackage on Linux?
IMO as of right now using swift-system SwiftPM package consistently on all platforms is the easiest approach and gives you best compatibility with the rest of the ecosystem of existing packages that do the same. This may change in the future if this pitch proceeds further somehow "Pitch: System in the toolchain".
We used to do this, but this approach is problematic if you later on need to interact with other packages that also use System(Package) but use conditional imports to pick one or the other on Apple vs. non-Apple platforms. swift-subprocess was the one that made us have to switch over to conditional imports.
We want to get out of the current mess with the multiple imports long-term but there’s still some philosophical issues to sort through. FilePath moving to the stdlib would greatly alleviate these and help swift-system clarify its role (and whether or where it belongs in the stack).
One question is whether we are providing a POSIX-esque world view for files or a very platform-specific approach. POSIX style int32 descriptors and Windows style DWORD* handles are a quite bit different from each other the further into the weeds you get.
What are your needs from this type?
And yes indeed I just happen to be using swift-subprocess at the same time, so yesterday I did resort to #if dance.
Now the imports are even more chaotic just because we want to drop full Foundation:
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#if canImport(System)
import System
#else
import SystemPackage
#endif
Really hope we can avoid this madness in a near future...