Replace compile-time directives with target platform conditions (#143)

* Replace compile-time directives with target platform conditions

Use Package.swift target platform conditions instead of compile-time #if directives for EventSource dependency. This leverages Swift Package Manager's native dependency support for platform-specific targets at runtime rather than compile-time.

* Update reference for EventSource package

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattt <mattt@me.com>
This commit is contained in:
Pedro Piñera Buendía 2025-08-10 14:52:50 +02:00 • committed by GitHub
commit 778ab33d23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,21 +7,16 @@ import PackageDescription
var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/apple/swift-system.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.0"),
.package(url: "https://github.com/mattt/eventsource.git", from: "1.1.0")
]
// Target dependencies needed on all platforms
var targetDependencies: [Target.Dependency] = [
.product(name: "SystemPackage", package: "swift-system"),
.product(name: "Logging", package: "swift-log"),
.product(name: "EventSource", package: "eventsource", condition: .when(platforms: [.macOS, .iOS, .tvOS, .visionOS, .watchOS]))
]
// Add EventSource only on Apple platforms (non-Linux)
#if !os(Linux)
dependencies.append(
.package(url: "https://github.com/loopwork-ai/eventsource.git", from: "1.1.0"))
targetDependencies.append(.product(name: "EventSource", package: "eventsource"))
#endif
let package = Package(
name: "mcp-swift-sdk",
platforms: [