From dd54a109d18c10e616c5dddd1b2aa84c1ba266a3 Mon Sep 17 00:00:00 2001 From: Maksim Orlovich Date: Tue, 31 Jul 2018 14:34:41 -0500 Subject: [PATCH] NSNotificationCenter.addObserver(forName:object:queue:using:) on Linux Swift >4.0 --- Package.swift | 1 + Sources/NSNotificationCenter+Promise.swift | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index c5319d0..6072eb0 100644 --- a/Package.swift +++ b/Package.swift @@ -5,6 +5,7 @@ let package = Package( dependencies: [ .Package(url: "https://github.com/mxcl/PromiseKit.git", majorVersion: 6) ], + swiftLanguageVersions: [3, 4], exclude: [ "Sources/NSNotificationCenter+AnyPromise.m", "Sources/NSTask+AnyPromise.m", diff --git a/Sources/NSNotificationCenter+Promise.swift b/Sources/NSNotificationCenter+Promise.swift index ad1113e..2db6a8d 100644 --- a/Sources/NSNotificationCenter+Promise.swift +++ b/Sources/NSNotificationCenter+Promise.swift @@ -25,7 +25,11 @@ extension NotificationCenter { #if !os(Linux) let id = addObserver(forName: name, object: object, queue: nil, using: fulfill) #else - let id = addObserver(forName: name, object: object, queue: nil, usingBlock: fulfill) + #if swift(>=4.0.1) + let id = addObserver(forName: name, object: object, queue: nil, using: fulfill) + #else + let id = addObserver(forName: name, object: object, queue: nil, usingBlock: fulfill) + #endif #endif promise.done { _ in self.removeObserver(id) } return promise