mirror of
https://github.com/apple/swift-nio-transport-services
synced 2026-11-22 04:30:44 +00:00
Only depend on NIOFoundationCompat on Apple platforms ### Motivation: https://github.com/apple/swift-nio-transport-services/pull/211#issuecomment-4170778092 ### Modifications: Only depend on NIOFoundationCompat on Apple platforms because it's only imported when Network can also be imported, so we don't unnecessarily depend transitively on Foundation. (We should use anyAppleOS as the condition if/when it becomes available in SPM too: https://forums.swift.org/t/introducing-anyappleos/85728 ) ### Result: Stripped release binary is 20MB instead of 65MB in a project using mqtt-nio --------- Co-authored-by: Cory Benfield <lukasa@apple.com>
111 lines
4.0 KiB
Swift
111 lines
4.0 KiB
Swift
// swift-tools-version:6.1
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftNIO open source project
|
|
//
|
|
// Copyright (c) 2017-2025 Apple Inc. and the SwiftNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import PackageDescription
|
|
|
|
let applePlatforms: [Platform] = [.iOS, .macOS, .tvOS, .watchOS, .macCatalyst, .driverKit, .visionOS]
|
|
|
|
let strictConcurrencyDevelopment = false
|
|
|
|
let strictConcurrencySettings: [SwiftSetting] = {
|
|
var initialSettings: [SwiftSetting] = []
|
|
|
|
if strictConcurrencyDevelopment {
|
|
// -warnings-as-errors here is a workaround so that IDE-based development can
|
|
// get tripped up on -require-explicit-sendable.
|
|
initialSettings.append(.unsafeFlags(["-Xfrontend", "-require-explicit-sendable", "-warnings-as-errors"]))
|
|
}
|
|
|
|
return initialSettings
|
|
}()
|
|
|
|
let package = Package(
|
|
name: "swift-nio-transport-services",
|
|
products: [
|
|
.library(name: "NIOTransportServices", targets: ["NIOTransportServices"])
|
|
],
|
|
dependencies: [
|
|
.package(url: "https://github.com/apple/swift-nio.git", from: "2.83.0"),
|
|
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.2"),
|
|
],
|
|
targets: [
|
|
.target(
|
|
name: "NIOTransportServices",
|
|
dependencies: [
|
|
.product(name: "NIO", package: "swift-nio"),
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(
|
|
name: "NIOFoundationCompat",
|
|
package: "swift-nio",
|
|
condition: .when(platforms: applePlatforms)
|
|
),
|
|
.product(name: "NIOTLS", package: "swift-nio"),
|
|
.product(name: "Atomics", package: "swift-atomics"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.executableTarget(
|
|
name: "NIOTSHTTPClient",
|
|
dependencies: [
|
|
"NIOTransportServices",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOHTTP1", package: "swift-nio"),
|
|
]
|
|
),
|
|
.executableTarget(
|
|
name: "NIOTSHTTPServer",
|
|
dependencies: [
|
|
"NIOTransportServices",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOHTTP1", package: "swift-nio"),
|
|
]
|
|
),
|
|
.executableTarget(
|
|
name: "NIOTSEchoClient",
|
|
dependencies: [
|
|
"NIOTransportServices",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
]
|
|
),
|
|
.testTarget(
|
|
name: "NIOTransportServicesTests",
|
|
dependencies: [
|
|
"NIOTransportServices",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOEmbedded", package: "swift-nio"),
|
|
.product(name: "NIOPosix", package: "swift-nio"),
|
|
.product(name: "Atomics", package: "swift-atomics"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
]
|
|
)
|
|
|
|
// --- STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
|
|
for target in package.targets {
|
|
switch target.type {
|
|
case .regular, .test, .executable:
|
|
var settings = target.swiftSettings ?? []
|
|
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
|
|
settings.append(.enableUpcomingFeature("MemberImportVisibility"))
|
|
target.swiftSettings = settings
|
|
case .macro, .plugin, .system, .binary:
|
|
() // not applicable
|
|
@unknown default:
|
|
() // we don't know what to do here, do nothing
|
|
}
|
|
}
|
|
// --- END: STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
|