Skip to content

Commit 3d2bc6e

Browse files
authored
Allow For Compilation on Windows & Add CI (pointfreeco#123)
* Ensure files can import SwiftUI * Add Windows CI Definition
1 parent 9299135 commit 3d2bc6e

28 files changed

+79
-2
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,27 @@ jobs:
2626
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
2727
- name: Run tests
2828
run: make test
29+
30+
windows:
31+
name: Windows
32+
strategy:
33+
matrix:
34+
os: [windows-latest]
35+
config: ['debug', 'release']
36+
fail-fast: false
37+
runs-on: ${{ matrix.os }}
38+
steps:
39+
- uses: compnerd/gha-setup-swift@main
40+
with:
41+
branch: swift-5.8.1-release
42+
tag: 5.8.1-RELEASE
43+
- uses: actions/checkout@v3
44+
- name: Build
45+
run: swift build -c ${{ matrix.config }}
46+
- name: Run tests (debug only)
47+
# There is an issue that exists in the 5.8.1 toolchain
48+
# which fails on release configuration testing, but
49+
# this issue is fixed 5.9 so we can remove the if once
50+
# that is generally available.
51+
if: ${{ matrix.config == 'debug' }}
52+
run: swift test

Sources/SwiftUINavigation/Alert.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
extension View {
@@ -303,3 +304,4 @@ extension View {
303304

304305
// TODO: support iOS <15?
305306
}
307+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/Binding.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
extension Binding {
@@ -187,3 +188,4 @@ extension Binding {
187188
)
188189
}
189190
}
191+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/ConfirmationDialog.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
extension View {
@@ -313,3 +314,4 @@ extension View {
313314

314315
// TODO: support iOS <15?
315316
}
317+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/FullScreenCover.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
extension View {
@@ -87,3 +88,4 @@ extension View {
8788
self.fullScreenCover(unwrapping: `enum`.case(casePath), onDismiss: onDismiss, content: content)
8889
}
8990
}
91+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/IfCaseLet.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
/// A view that computes content by extracting a case from a binding to an enum and passing a
@@ -90,3 +91,4 @@ extension IfCaseLet where ElseContent == EmptyView {
9091
self.ifContent = ifContent
9192
}
9293
}
94+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/IfLet.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
/// A view that computes content by unwrapping a binding to an optional and passing a non-optional
@@ -84,3 +85,4 @@ extension IfLet where ElseContent == EmptyView {
8485
self.init(value, then: ifContent, else: { EmptyView() })
8586
}
8687
}
88+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/Internal/Binding+Internal.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
extension Binding {
@@ -11,3 +12,4 @@ extension Binding {
1112
)
1213
}
1314
}
15+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/Internal/Deprecations.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
// NB: Deprecated after 0.5.0
@@ -218,3 +219,4 @@ extension NavigationLink {
218219
)
219220
}
220221
}
222+
#endif // canImport(SwiftUI)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
#if canImport(SwiftUI)
12
@_exported import CasePaths
23
@_exported import SwiftUINavigationCore
4+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/NavigationDestination.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if swift(>=5.7)
1+
#if swift(>=5.7) && canImport(SwiftUI)
22
import SwiftUI
33

44
@available(iOS 16, macOS 13, tvOS 16, watchOS 9, *)
@@ -107,4 +107,4 @@
107107
else { return true }
108108
return false
109109
}()
110-
#endif
110+
#endif // swift(>=5.7) && canImport(SwiftUI)

Sources/SwiftUINavigation/NavigationLink.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
extension NavigationLink {
@@ -133,3 +134,4 @@ extension NavigationLink {
133134
)
134135
}
135136
}
137+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/Popover.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
extension View {
@@ -96,3 +97,4 @@ extension View {
9697
)
9798
}
9899
}
100+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/Sheet.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
#if canImport(UIKit)
@@ -87,3 +88,4 @@ extension View {
8788
self.sheet(unwrapping: `enum`.case(casePath), onDismiss: onDismiss, content: content)
8889
}
8990
}
91+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/Switch.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23
@_spi(RuntimeWarn) import SwiftUINavigationCore
34

@@ -1114,3 +1115,4 @@ private func describeCase<Enum>(_ enum: Enum) -> String {
11141115
}
11151116
return "\(type).\(`case`)"
11161117
}
1118+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigation/WithState.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
/// A container view that provides a binding to another view.
@@ -44,3 +45,4 @@ public struct WithState<Value, Content: View>: View {
4445
self.content(self.$value)
4546
}
4647
}
48+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigationCore/AlertState.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import CustomDump
23
import SwiftUI
34

@@ -260,3 +261,4 @@ extension Alert {
260261
}
261262
}
262263
}
264+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigationCore/Bind.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
extension View {
@@ -82,3 +83,4 @@ extension FocusState.Binding: _Bindable {}
8283
extension SceneStorage: _Bindable {}
8384

8485
extension State: _Bindable {}
86+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigationCore/ButtonState.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import CustomDump
23
import SwiftUI
34

@@ -368,3 +369,4 @@ func typeName(_ type: Any.Type) -> String {
368369
)
369370
return sanitizedName
370371
}
372+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigationCore/ButtonStateBuilder.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
@resultBuilder
23
public enum ButtonStateBuilder<Action> {
34
public static func buildArray(_ components: [[ButtonState<Action>]]) -> [ButtonState<Action>] {
@@ -30,3 +31,4 @@ public enum ButtonStateBuilder<Action> {
3031
component ?? []
3132
}
3233
}
34+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigationCore/ConfirmationDialogState.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import CustomDump
23
import SwiftUI
34

@@ -288,3 +289,4 @@ extension Visibility {
288289
}
289290
}
290291
}
292+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigationCore/Internal/Deprecations.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23

34
// NB: Deprecated after 0.5.0
@@ -307,3 +308,5 @@ extension ActionSheet {
307308
)
308309
}
309310
}
311+
312+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigationCore/Internal/RuntimeWarnings.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
@_spi(RuntimeWarn)
23
@_transparent
34
@inline(__always)
@@ -70,3 +71,4 @@ public func runtimeWarn(
7071
}()
7172
#endif
7273
#endif
74+
#endif // canImport(SwiftUI)

Sources/SwiftUINavigationCore/TextState.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import CustomDump
23
import SwiftUI
34

@@ -741,3 +742,4 @@ extension TextState: CustomDumpRepresentable {
741742
return dumpHelp(self)
742743
}
743744
}
745+
#endif // canImport(SwiftUI)

Tests/SwiftUINavigationTests/AlertTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import CustomDump
23
import SwiftUI
34
import SwiftUINavigation
@@ -117,3 +118,4 @@ private struct TestView: View {
117118
}
118119
}
119120
}
121+
#endif // canImport(SwiftUI)

Tests/SwiftUINavigationTests/ButtonStateTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import CustomDump
23
import SwiftUI
34
import SwiftUINavigation
@@ -30,3 +31,4 @@ final class ButtonStateTests: XCTestCase {
3031
}
3132
}
3233
}
34+
#endif // canImport(SwiftUI)

Tests/SwiftUINavigationTests/SwiftUINavigationTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import SwiftUI
23
import XCTest
34

@@ -60,3 +61,4 @@ final class SwiftUINavigationTests: XCTestCase {
6061
XCTAssertEqual(failure.wrappedValue, nil)
6162
}
6263
}
64+
#endif // canImport(SwiftUI)

Tests/SwiftUINavigationTests/TextStateTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(SwiftUI)
12
import CustomDump
23
import SwiftUINavigation
34
import XCTest
@@ -72,3 +73,4 @@ final class TextStateTests: XCTestCase {
7273
)
7374
}
7475
}
76+
#endif // canImport(SwiftUI)

0 commit comments

Comments
 (0)