File tree 3 files changed +13
-0
lines changed
Examples/Sources/MacroExamples
3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
13
+ #if canImport(SwiftUI)
14
+
13
15
import SwiftUI
14
16
15
17
// MARK: - EnvironmentValue Accessor
@@ -18,3 +20,5 @@ import SwiftUI
18
20
@attached ( accessor)
19
21
public macro EnvironmentValue( for key: any EnvironmentKey . Type ) =
20
22
#externalMacro( module: " MacroExamplesImplementation " , type: " EnvironmentValueMacro " )
23
+
24
+ #endif
Original file line number Diff line number Diff line change 13
13
// MARK: - EnvironmentValue Accessor
14
14
15
15
import MacroExamplesInterface
16
+
17
+ #if canImport(SwiftUI)
18
+
16
19
import SwiftUI
17
20
18
21
private struct MyEnvironmentKey : EnvironmentKey {
@@ -30,3 +33,5 @@ func runEnvironmentValueAccessorMacroPlayground() {
30
33
environmentValues. myCustomValue = " New value "
31
34
print ( " New myCustomValue: \( environmentValues. myCustomValue) " )
32
35
}
36
+
37
+ #endif
Original file line number Diff line number Diff line change @@ -50,4 +50,8 @@ runPeerMacrosPlayground()
50
50
51
51
// MARK: - Accessor Macros
52
52
53
+ #if canImport(SwiftUI)
54
+
53
55
runEnvironmentValueAccessorMacroPlayground ( )
56
+
57
+ #endif
You can’t perform that action at this time.
0 commit comments