Skip to content

Commit

Permalink
Improve multiplatform support
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLeif committed Jan 23, 2024
1 parent 1c8e3ed commit 398823a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#if os(Linux) || os(Windows)
open class ApplicationLogger {
open func log(
debug message: String,
open func debug(
_ message: String,
fileID: StaticString,
function: StaticString,
line: Int,
Expand All @@ -16,8 +16,8 @@ open class ApplicationLogger {
)
}

open func log(
debug message: () -> String,
open func debug(
_ message: () -> String,
fileID: StaticString,
function: StaticString,
line: Int,
Expand All @@ -32,8 +32,8 @@ open class ApplicationLogger {
)
}

open func log(
error: Error,
open func error(
_ error: Error,
message: String,
fileID: StaticString,
function: StaticString,
Expand Down
6 changes: 5 additions & 1 deletion Tests/AppStateTests/AppStateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ fileprivate extension Application {
}
}

fileprivate class ExampleViewModel: ObservableObject {
fileprivate class ExampleViewModel {
@AppState(\.username) var username

func testPropertyWrapper() {
username = "Hello, ExampleView"
}
}

#if !os(Linux) && !os(Windows)
extension ExampleViewModel: ObservableObject { }
#endif

fileprivate struct ExampleView {
@AppState(\.username) var username
@AppState(\.isLoading) var isLoading
Expand Down
6 changes: 5 additions & 1 deletion Tests/AppStateTests/OptionalSliceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fileprivate extension Application {
}
}

fileprivate class ExampleViewModel: ObservableObject {
fileprivate class ExampleViewModel {
@OptionalSlice(\.exampleValue, \.username) var username
@OptionalConstant(\.exampleValue, \.value) var value
@OptionalSlice(\.exampleValue, \.isLoading) var isLoading
Expand All @@ -33,6 +33,10 @@ fileprivate class ExampleViewModel: ObservableObject {
}
}

#if !os(Linux) && !os(Windows)
extension ExampleViewModel: ObservableObject { }
#endif

fileprivate struct ExampleView {
@OptionalSlice(\.exampleValue, \.username) var username
@OptionalSlice(\.exampleValue, \.isLoading) var isLoading
Expand Down
5 changes: 1 addition & 4 deletions Tests/AppStateTests/SecureStateTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import Foundation
#if !os(Linux) && !os(Windows)
import SwiftUI
#endif
import XCTest
@testable import AppState

Expand All @@ -20,9 +18,7 @@ fileprivate class ExampleSecureViewModel: ObservableObject {

func testPropertyWrapper() {
token = "QWERTY"
#if !os(Linux) && !os(Windows)
_ = Picker("Picker", selection: $token, content: EmptyView.init)
#endif
}
}

Expand Down Expand Up @@ -75,3 +71,4 @@ final class SecureStateTests: XCTestCase {
XCTAssertNil(viewModel.token)
}
}
#endif
6 changes: 5 additions & 1 deletion Tests/AppStateTests/SliceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fileprivate extension Application {
}
}

fileprivate class ExampleViewModel: ObservableObject {
fileprivate class ExampleViewModel {
@Slice(\.exampleValue, \.username) var username
@Constant(\.exampleValue, \.value) var value

Expand All @@ -34,6 +34,10 @@ fileprivate class ExampleViewModel: ObservableObject {
}
}

#if !os(Linux) && !os(Windows)
extension ExampleViewModel: ObservableObject { }
#endif

fileprivate struct ExampleView {
@Slice(\.exampleValue, \.username) var username
@Slice(\.exampleValue, \.isLoading) var isLoading
Expand Down
6 changes: 5 additions & 1 deletion Tests/AppStateTests/StoredStateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fileprivate struct ExampleStoredValue {
@StoredState(\.storedValue) var count
}

fileprivate class ExampleStoringViewModel: ObservableObject {
fileprivate class ExampleStoringViewModel {
@StoredState(\.storedValue) var count

func testPropertyWrapper() {
Expand All @@ -30,6 +30,10 @@ fileprivate class ExampleStoringViewModel: ObservableObject {
}
}

#if !os(Linux) && !os(Windows)
extension ExampleStoringViewModel: ObservableObject { }
#endif

final class StoredStateTests: XCTestCase {
override class func setUp() {
Application.logging(isEnabled: true)
Expand Down

0 comments on commit 398823a

Please sign in to comment.