Open edmw opened 4 years ago
Same issue. How is possible to fix this ? thanks!
@malcommac Please consider either fixing this or removing the claim that this library works for Linux.
Same here, please consider fixing this, thanks.
Unfortunately DateComponentsFormatter isn't implemented yet https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md
There is only one way to compile SwiftDate library on Linux - disable using of DateComponentsFormatter. I've made changes to compile my project on Linux. You can use it:
.package(url: "https://github.com/Maxim-Inv/SwiftDate.git", .branch("master")),
Any update on this?
Please we need this!.
@Kishimotovn you can use my fix:
.package(url: "https://github.com/Maxim-Inv/SwiftDate.git", .branch("master")),
first "commented on 31 Dec 2019" really? not yet? ..probably never..
@bordunosp You can use my fork, I have just update it
.package(url: "https://github.com/Maxim-Inv/SwiftDate.git", .branch("master")),
@bordunosp You can use my fork, I have just update it
.package(url: "https://github.com/Maxim-Inv/SwiftDate.git", .branch("master")),
My regards. Refused already from half of the external packages) I don't think swift is ready for Linux, although I want to use it now)) A very contradictory feeling
You shouldn't think so. But you should be ready to make fixes if you really need some package in your project. Or wait when someone makes it. I started with Vapor 3, then moved to the beta version of Vapor 4, and only recently it became a full release version. I have five projects running on the Linux, so I can confidently say that Swift works well.
You shouldn't think so. But you should be ready to make fixes if you really need some package in your project. Or wait when someone makes it. I started with Vapor 3, then moved to the beta version of Vapor 4, and only recently it became a full release version. I have five projects running on the Linux, so I can confidently say that Swift works well.
what do you use to communicate with external API? Some kind of REST requests module? The default URLSession, like Alamofire, is very awkward to use. Maybe you can suggest something usable with habitual ".wait()"
So I'm using Vapor for a server application, I use the inner Vapor class to get data from a remote server. Why do you think URLSession is very awkward? I guess that you did not deal with what was before in Objective C, that was really uncomfortable.
Vapor is not my way). Using clear grpc services
URLSession is uncomfortable because swift still have not paradigm "async/await" and I must use DispatchSemaphore vs DispatchGroup together. Although, perhaps my approach is fundamentally wrong. Perhaps you will look at the code and help a newbie with a specific example (although the question is already far from the original issue :))
var error: Error?
var newFilePathPart: String?
let group = DispatchGroup(); group.enter(); DispatchQueue.global(qos: .userInteractive).async {
let semaphore = DispatchSemaphore(value: 0)
let sessionConfig = URLSessionConfiguration.default
sessionConfig.timeoutIntervalForRequest = (Date() + jobTimeout.seconds).timeIntervalSinceNow
URLSession(configuration: sessionConfig).downloadTask(with: fileUrl) {(tmpFile, response, err) in
do {
guard err == nil else {
throw err!
}
guard tmpFile != nil else {
throw ErrorsHelper.Server(msg: "Cant unwrap tmpFile")
}
let mime = try MimeTypeHelper.byFilePath(tmpFile!.path)
guard allowedExts.count == 0 || allowedExts.contains(mime.ext) else {
throw ErrorsHelper.Server(msg: "Current ext '\(mime.ext)' not allowed by allowedExts: \(allowedExts.joined(separator:","))")
}
var fileName = ""
let fileData = try Data(contentsOf: tmpFile!)
let datePath = "\(Date().year)-\(Date().month)"
let savePath = Path.cwd.join(ConfigHelper.shared.path.staticPath).join(saveTo).join(datePath)
if !savePath.isDirectory {
try savePath.mkdir(MakeDirectoryOptions.p)
}
repeat {
fileName = "".random(length: 32).lowercased() + ".\(mime.ext)"
} while savePath.join(fileName).isFile
try fileData.write(to: savePath.join(fileName))
newFilePathPart = "\(datePath)/\(fileName)"
} catch let err {
error = err
}
semaphore.signal()
}.resume()
semaphore.wait()
group.leave()
}; group.wait(); guard error == nil else {
throw ErrorsHelper.Server(msg: "Cant download file by url: \(url) -> \(error!)")
}
I think this is what I was looking for: https://www.perfect.org/docs/cURL.html Looks pretty good (without DispatchGroup and Semaphore, and still can throw exception inside call method - perfect)
let url = "https://httpbin.org/get?p1=v1&p2=v2"
if let json = try CURLRequest(url).promise().then { return try $0().bodyJSON }.wait() {
...
}
@Maxim-Inv are you serious? your fork only disabled few lines of code (half of which are tests). Why doesnt the project owner not merge it?
@patchthecode as you said I just commented a few lines of code only to avoid error on Linux. I think it only a workaround, not a fix.
Irrespective on this library, I'm having the same problem today on Linux.
Unbelievable that both RelativeDateTimeFormatter and DateComponentsFormatter are unavailable in the official Swift image (using 5.9.2).
Getting
error: cannot find 'RelativeDateTimeFormatter' in scope
error: 'DateComponentsFormatter' is unavailable: Not supported in swift-corelibs-foundation
Not sure what else to use.
Hi,
when compiling with Linux I get this error (using version 6.1 and Swift 5):
Seems to me that DateComponentsFormatter is not available for Linux (unfortunately, I couldn't find out if it‘s just not there yet or never will be).
Any idea how I can get around this?