Skip to content

Commit 4fa1f95

Browse files
committed
Added extension specific library
1 parent bc20d7e commit 4fa1f95

15 files changed

+74
-3
lines changed

Package.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,17 @@ let package = Package(
1414
// Products define the executables and libraries a package produces, and make them visible to other packages.
1515
.library(
1616
name: "DJSwiftHelpers",
17-
targets: ["DJSwiftHelpers", "DJSwiftHelpers_UIKit", "DJSwiftHelpers_SwiftUI"]
18-
)
17+
targets: [
18+
"DJSwiftHelpers",
19+
"DJSwiftHelpers_UIKit",
20+
"DJSwiftHelpers_SwiftUI"
21+
]
22+
),
23+
.library(name: "DJSwiftHelpers_Extension",
24+
targets: [
25+
"DJSwiftHelpers",
26+
"DJSwiftHelpers_SwiftUI"
27+
])
1928
],
2029
targets: [
2130
// Targets are the basic building blocks of a package. A target can define a module or a test suite.

Sources/SwiftUI/OnFirstAppear.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2022 Dappological Ltd. All rights reserved.
77
//
88

9+
#if canImport(SwiftUI)
910
import SwiftUI
1011

1112
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *)
@@ -41,3 +42,4 @@ struct FirstAppear: ViewModifier {
4142
}
4243
}
4344
}
45+
#endif

Sources/SwiftUI/OpenInSafari.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2022 Dappological Ltd. All rights reserved.
77
//
88

9+
#if canImport(SwiftUI)
910
#if os(iOS)
1011
// SwiftUI isn't available in the armv7 architecture
1112
#if arch(arm64) || arch(x86_64)
@@ -120,3 +121,4 @@ class SafariActivity: UIActivity {
120121
}
121122
#endif // arch(arm64) || arch(x86_64)
122123
#endif // os(iOS)
124+
#endif // canImport(SwiftUI)

Sources/UIKit/Gradient.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2021 Dappological Ltd. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
910
import UIKit
1011

1112
/**
@@ -25,6 +26,8 @@ import UIKit
2526
}
2627
```
2728
*/
29+
#if !os(watchOS)
30+
@available(iOS 2.0, macCatalyst 13.1, tvOS 9.0, *)
2831
@IBDesignable
2932
open class Gradient: UIView {
3033
@IBInspectable open var startColor: UIColor = .black { didSet { updateColors() }}
@@ -60,3 +63,5 @@ open class Gradient: UIView {
6063
updateColors()
6164
}
6265
}
66+
#endif
67+
#endif

Sources/UIKit/NSMutableAttributedString.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
// Copyright © 2022 Dappological Ltd. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
910
import UIKit
1011

12+
@available(iOS 2.0, macCatalyst 13.1, tvOS 9.0, watchOS 2.0, *)
1113
public
1214
extension NSMutableAttributedString {
1315

@@ -22,3 +24,4 @@ extension NSMutableAttributedString {
2224
self.addAttribute(NSAttributedString.Key.foregroundColor, value: color, range: range)
2325
}
2426
}
27+
#endif

Sources/UIKit/UIApplication.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
// Copyright © 2020 Dappological Ltd. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
910
import UIKit
1011

12+
#if !os(watchOS)
13+
@available(iOS 2.0, macCatalyst 13.1, tvOS 9.0, *)
1114
public
1215
extension UIApplication {
1316

@@ -60,3 +63,5 @@ extension UIApplication {
6063
UIWindow.key?.rootViewController?.dismiss(animated: animated, completion: completion)
6164
}
6265
}
66+
#endif
67+
#endif

Sources/UIKit/UIColor.swift

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

9+
#if canImport(UIKit)
910
import UIKit
1011

12+
@available(iOS 2.0, macCatalyst 13.1, tvOS 9.0, watchOS 2.0, *)
1113
public
1214
extension UIColor {
1315

@@ -44,6 +46,7 @@ extension UIColor {
4446
}
4547
}
4648

49+
@available(iOS 2.0, macCatalyst 13.1, tvOS 9.0, watchOS 2.0, *)
4750
public
4851
extension UIColor {
4952

@@ -55,3 +58,4 @@ extension UIColor {
5558
return getRed(&r, green: &g, blue: &b, alpha: &a) ? UIColor(red: 1.0-r, green: 1.0-g, blue: 1.0-b, alpha: a) : .black
5659
}
5760
}
61+
#endif

Sources/UIKit/UIDevice.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
// Copyright © 2020 Dappological Ltd. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
910
import UIKit
1011

12+
#if !os(watchOS)
13+
@available(iOS 2.0, macCatalyst 13.1, tvOS 9.0, *)
1114
public
1215
extension UIDevice {
1316

@@ -27,3 +30,5 @@ extension UIDevice {
2730
return UIDevice.current.userInterfaceIdiom == .carPlay
2831
}
2932
}
33+
#endif
34+
#endif

Sources/UIKit/UIFont.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
// Copyright © 2021 Dappological Ltd. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
910
import UIKit
1011

11-
@available(iOS 11.0, *)
12+
@available(iOS 11.0, macCatalyst 13.1, tvOS 11.0, watchOS 4.0, *)
1213
public
1314
extension UIFont {
1415

@@ -30,3 +31,4 @@ extension UIFont {
3031
return metrics.scaledFont(for: font)
3132
}
3233
}
34+
#endif

Sources/UIKit/UIImage.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
// Copyright © 2020 Dappological Ltd. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
910
import UIKit
1011

12+
@available(iOS 2.0, macCatalyst 13.1, tvOS 9.0, watchOS 2.0, *)
1113
public
1214
extension UIImage {
1315

@@ -47,6 +49,8 @@ extension UIImage {
4749
}
4850
}
4951

52+
#if !os(watchOS)
53+
@available(iOS 2.0, macCatalyst 13.1, tvOS 9.0, *)
5054
public
5155
extension UIImage {
5256

@@ -76,3 +80,6 @@ extension UIImage {
7680
return newImage!
7781
}
7882
}
83+
#endif
84+
85+
#endif

0 commit comments

Comments
 (0)