From 54eca408c70474709d9a47a5829d537637833262 Mon Sep 17 00:00:00 2001 From: ened Date: Mon, 29 May 2023 00:14:08 +0900 Subject: [PATCH] Build on linux environment (ubuntu 20.4) --- .gitignore | 4 ++++ KissMe/Sources/Common/KissExtensions.swift | 25 ++++++++++++++++++++++ KissMe/Sources/Common/Request.swift | 4 ++++ KissMe/Sources/Common/SeibroRequest.swift | 5 +++++ KissMeConsole/Package.swift | 2 +- 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8808bcb --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.build +.swiftpm +.DS_Store +bin diff --git a/KissMe/Sources/Common/KissExtensions.swift b/KissMe/Sources/Common/KissExtensions.swift index f3463b4..4f22db4 100644 --- a/KissMe/Sources/Common/KissExtensions.swift +++ b/KissMe/Sources/Common/KissExtensions.swift @@ -37,3 +37,28 @@ extension Date { ProcessInfo.processInfo.systemUptime } } + +#if os(Linux) +extension URL { + public static func currentDirectory() -> URL { + URL(fileURLWithPath: FileManager.default.currentDirectoryPath) + } + + public mutating func append(path: String) { + appendPathComponent(path) + } + + public func appending(path: String) -> URL { + appendingPathComponent(path) + } + + public mutating func append(queryItems: [URLQueryItem]) { + var components = URLComponents(url: self, resolvingAgainstBaseURL: true) + components?.queryItems = queryItems + if let url = components?.url { + self = url + } + } +} +#endif + diff --git a/KissMe/Sources/Common/Request.swift b/KissMe/Sources/Common/Request.swift index 10002ab..e322c85 100644 --- a/KissMe/Sources/Common/Request.swift +++ b/KissMe/Sources/Common/Request.swift @@ -7,6 +7,10 @@ import Foundation +#if os(Linux) +import FoundationNetworking +#endif + public enum Method { case `get` diff --git a/KissMe/Sources/Common/SeibroRequest.swift b/KissMe/Sources/Common/SeibroRequest.swift index ed4a017..f429bbf 100644 --- a/KissMe/Sources/Common/SeibroRequest.swift +++ b/KissMe/Sources/Common/SeibroRequest.swift @@ -7,6 +7,11 @@ import Foundation +#if os(Linux) +import FoundationNetworking +import FoundationXML +#endif + protocol SeibroRequest: Request { var openApiKey: String { get } diff --git a/KissMeConsole/Package.swift b/KissMeConsole/Package.swift index 7df65dc..bea8bfc 100644 --- a/KissMeConsole/Package.swift +++ b/KissMeConsole/Package.swift @@ -22,7 +22,7 @@ let package = Package( targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target( + .executableTarget( name: "KissMeConsole", dependencies: ["KissMe"], path: "Sources"),