Skip to content

Commit 6418699

Browse files
committed
Add platform check
1 parent 10a6999 commit 6418699

22 files changed

+223
-182
lines changed

EasyClosure.xcodeproj/project.pbxproj

Lines changed: 156 additions & 122 deletions
Large diffs are not rendered by default.

EasyClosureTests/Mac/macOSTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if canImport(AppKit)
2+
13
import XCTest
24
import EasyClosure
35

@@ -18,3 +20,5 @@ class macOSTests: XCTestCase {
1820
button.on.tap {}
1921
}
2022
}
23+
24+
#endif

EasyClosureTests/iOS/iOSTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if canImport(UIKit) && os(iOS)
2+
13
import XCTest
24
import EasyClosure
35
import UIKit
@@ -9,3 +11,5 @@ class EasyClosureTests: XCTestCase {
911
button.on.tap {}
1012
}
1113
}
14+
15+
#endif

Package.swift

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,28 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.1
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33
import PackageDescription
44

55
let package = Package(
66
name: "EasyClosure",
77
platforms: [
8-
.macOS(.v10_13),
9-
.iOS(.v10),
10-
.tvOS(.v11)
8+
.macOS(.v10_15),
9+
.iOS(.v13),
10+
.tvOS(.v13),
11+
.watchOS(.v6)
1112
],
1213
products: [
1314
.library(
1415
name: "EasyClosure",
15-
targets: ["EasyClosureiOS"]
16-
),
17-
.library(
18-
name: "EasyClosure",
19-
targets: ["EasyClosuremacOS"]
20-
)
21-
],
22-
dependencies: [
23-
// Dependencies declare other packages that this package depends on.
24-
// .package(url: /* package url */, from: "1.0.0"),
16+
targets: ["EasyClosure"]),
2517
],
2618
targets: [
2719
.target(
28-
name: "EasyClosureiOS",
29-
dependencies: [],
30-
path: "Sources",
31-
sources: ["Shared", "iOS"]
32-
),
33-
.target(
34-
name: "EasyClosuremacOS",
35-
dependencies: [],
36-
path: "Sources",
37-
sources: ["Shared", "macOS"]
20+
name: "EasyClosure",
21+
path: "Sources"
3822
),
3923
.testTarget(
4024
name: "EasyClosureTests",
41-
dependencies: ["EasyClosure"],
42-
path: "EasyClosureTests/iOS"
43-
),
44-
]
25+
dependencies: ["EasyClosure"]),
26+
],
27+
swiftLanguageVersions: [.v5]
4528
)

Playground-Mac.playground/Contents.swift

Lines changed: 0 additions & 6 deletions
This file was deleted.

Playground-Mac.playground/contents.xcplayground

Lines changed: 0 additions & 4 deletions
This file was deleted.

Playground-Mac.playground/timeline.xctimeline

Lines changed: 0 additions & 6 deletions
This file was deleted.

Playground-iOS.playground/Contents.swift

Lines changed: 0 additions & 6 deletions
This file was deleted.

Playground-iOS.playground/contents.xcplayground

Lines changed: 0 additions & 4 deletions
This file was deleted.

Playground-iOS.playground/timeline.xctimeline

Lines changed: 0 additions & 6 deletions
This file was deleted.

Sources/iOS/UIBarButtonItem.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Copyright © 2019 Khoa Pham. All rights reserved.
66
//
77

8+
#if canImport(UIKit) && os(iOS)
9+
810
import UIKit
911

1012
public extension Container where Host: UIBarButtonItem {
@@ -31,3 +33,5 @@ class BarButtonItemTarget: NSObject {
3133
action?()
3234
}
3335
}
36+
37+
#endif

Sources/iOS/UIButton.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Copyright © 2019 Khoa Pham. All rights reserved.
66
//
77

8+
#if canImport(UIKit) && os(iOS)
9+
810
import UIKit
911

1012
public extension Container where Host: UIButton {
@@ -30,3 +32,5 @@ class ButtonTarget: NSObject {
3032
action?()
3133
}
3234
}
35+
36+
#endif

Sources/iOS/UIDatePicker.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Copyright © 2019 Khoa Pham. All rights reserved.
66
//
77

8+
#if canImport(UIKit) && os(iOS)
9+
810
import UIKit
911

1012
public extension Container where Host: UIDatePicker {
@@ -30,3 +32,5 @@ class DatePickerTarget: NSObject {
3032
action?(picker.date)
3133
}
3234
}
35+
36+
#endif

Sources/iOS/UIGestureRecognizer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Copyright © 2019 Khoa Pham. All rights reserved.
66
//
77

8+
#if canImport(UIKit) && os(iOS)
9+
810
import UIKit
911

1012
public extension Container where Host: UIGestureRecognizer {
@@ -30,3 +32,5 @@ class GestureTarget: NSObject {
3032
action?()
3133
}
3234
}
35+
36+
#endif

Sources/iOS/UISearchBar.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Copyright © 2019 Khoa Pham. All rights reserved.
66
//
77

8+
#if canImport(UIKit) && os(iOS)
9+
810
import UIKit
911

1012
public extension Container where Host: UISearchBar {
@@ -30,3 +32,5 @@ class SearchBarTarget: NSObject, UISearchBarDelegate {
3032
action?(searchText)
3133
}
3234
}
35+
36+
#endif

Sources/iOS/UISlider.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Copyright © 2019 Khoa Pham. All rights reserved.
66
//
77

8+
#if canImport(UIKit) && os(iOS)
9+
810
import UIKit
911

1012
public extension Container where Host: UISlider {
@@ -30,3 +32,5 @@ class SliderTarget: NSObject {
3032
action?(slider.value)
3133
}
3234
}
35+
36+
#endif

Sources/iOS/UISwitch.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2019 Khoa Pham. All rights reserved.
77
//
88

9+
#if canImport(UIKit) && os(iOS)
10+
911
import UIKit
1012

1113
public extension Container where Host: UISwitch {
@@ -31,3 +33,5 @@ class SwitchTarget: NSObject {
3133
action?(uiSwitch.isOn)
3234
}
3335
}
36+
37+
#endif

Sources/iOS/UITextField.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Copyright © 2019 Khoa Pham. All rights reserved.
66
//
77

8+
#if canImport(UIKit) && os(iOS)
9+
810
import UIKit
911

1012
public extension Container where Host: UITextField {
@@ -30,3 +32,5 @@ class TextFieldTarget: NSObject {
3032
textAction?(textField.text ?? "")
3133
}
3234
}
35+
36+
#endif

Sources/iOS/UITextView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Copyright © 2019 Khoa Pham. All rights reserved.
66
//
77

8+
#if canImport(UIKit) && os(iOS)
9+
810
import UIKit
911

1012
public extension Container where Host: UITextView {
@@ -30,3 +32,5 @@ class TextViewTarget: NSObject, UITextViewDelegate {
3032
action?(textView.text ?? "")
3133
}
3234
}
35+
36+
#endif

Sources/macOS/NSButton.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// Copyright © 2019 Khoa Pham. All rights reserved.
66
//
77

8+
#if canImport(AppKit)
9+
810
import AppKit
911

1012
public extension Container where Host: NSButton {
@@ -31,3 +33,5 @@ class ButtonTarget: NSObject {
3133
action?()
3234
}
3335
}
36+
37+
#endif

Sources/macOS/NSGestureRecognizer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2019 Khoa Pham. All rights reserved.
77
//
88

9+
#if canImport(AppKit)
10+
911
import AppKit
1012

1113
public extension Container where Host: NSGestureRecognizer {
@@ -31,3 +33,5 @@ class GestureTarget: NSObject {
3133
action?()
3234
}
3335
}
36+
37+
#endif

Sources/macOS/NSTextField.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2019 Khoa Pham. All rights reserved.
77
//
88

9+
#if canImport(AppKit)
10+
911
import AppKit
1012

1113
public extension Container where Host: NSTextField {
@@ -55,3 +57,5 @@ class TextFieldChangeTarget: NSObject, NSTextFieldDelegate {
5557
action?(textField.stringValue)
5658
}
5759
}
60+
61+
#endif

0 commit comments

Comments
 (0)