Skip to content

Commit

Permalink
Multi-platform tweaks similar to the Crypto library
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr. Brandon Wiley committed Nov 2, 2021
1 parent 3dbea63 commit 85bd4e2
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import PackageDescription

#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS))
let package = Package(
name: "Transmission",
platforms: [.macOS(.v10_15), .iOS(.v14)],
Expand Down Expand Up @@ -33,3 +34,36 @@ let package = Package(
],
swiftLanguageVersions: [.v5]
)
#else
let package = Package(
name: "Transmission",
platforms: [.macOS(.v10_15), .iOS(.v14)],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Transmission",
targets: ["Transmission"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/OperatorFoundation/Chord", from: "0.0.13"),
.package(url: "https://github.com/OperatorFoundation/Datable", from: "3.1.1"),
.package(url: "https://github.com/OperatorFoundation/Transport", from: "2.3.8"),
.package(url: "https://github.com/OperatorFoundation/TransmissionLinux", from: "0.4.0"),
],
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 which this package depends on.
.target(
name: "Transmission",
dependencies: ["Chord", "Datable", "Transport", "TransmissionLinux", .product(name: "Logging", package: "swift-log")]
),
.testTarget(
name: "TransmissionTests",
dependencies: ["Transmission", "Datable"]),
],
swiftLanguageVersions: [.v5]
)
#endif
8 changes: 8 additions & 0 deletions Sources/Transmission/Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Datable
import Transport
import Logging

#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS))

public class Connection
{
var connection: Transport.Connection
Expand Down Expand Up @@ -401,3 +403,9 @@ public func maybeLog(message: String, logger: Logger? = nil) {
print(message)
}
}

#else

@_exported import TransmissionLinux

#endif
8 changes: 8 additions & 0 deletions Sources/Transmission/Listener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Foundation
import Network
import Chord

#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS))

public class Listener
{
let listener: NWListener
Expand Down Expand Up @@ -49,3 +51,9 @@ public class Listener
return self.queue.dequeue()
}
}

#else

@_exported import TransmissionLinux

#endif

0 comments on commit 85bd4e2

Please sign in to comment.