Skip to content

Commit c7441aa

Browse files
committed
Add PreviewsMacros
1 parent bc690ea commit c7441aa

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ umbrella: umbrella-tmp
4444
umbrella-check: umbrella-tmp
4545
@if ! cmp -s $(UMBRELLA_TMP) $(UMBRELLA_FILE); then \
4646
echo "Umbrella file is out of date. Run 'make umbrella' to update it."; \
47-
cat $(UMBRELLA_TMP); \
48-
echo 'Current umbrella file:'; \
49-
cat $(UMBRELLA_FILE); \
5047
exit 1; \
5148
fi
5249

Package.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import PackageDescription
44

55
let macroTargets: [Target] = [
6+
.target(
7+
name: "PreviewsMacros",
8+
dependencies: ["OpenAppleMacrosBase"],
9+
),
610
.target(
711
name: "SwiftUIMacros",
812
dependencies: ["OpenAppleMacrosBase"],
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Generated with `make umbrella`. Do not modify manually.
22

3+
import PreviewsMacros
34
import SwiftDataMacros
45
import SwiftUIMacros
56

67
let allMacros = [
8+
PreviewsMacros.all,
79
SwiftDataMacros.all,
810
SwiftUIMacros.all,
911
]

Sources/PreviewsMacros/Macros.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import OpenAppleMacrosBase
2+
3+
// Stub macros to allow #Preview to compile.
4+
// We don't actually support viewing previews through xtool.
5+
6+
package let all: [Macro.Type] = [
7+
SwiftUIView.self,
8+
Previewable.self,
9+
]
10+
11+
struct SwiftUIView: DeclarationMacro {
12+
static func expansion(
13+
of node: some FreestandingMacroExpansionSyntax,
14+
in context: some MacroExpansionContext
15+
) throws -> [DeclSyntax] {
16+
return []
17+
}
18+
}
19+
20+
struct Previewable: PeerMacro {
21+
static func expansion(
22+
of node: AttributeSyntax,
23+
providingPeersOf declaration: some DeclSyntaxProtocol,
24+
in context: some MacroExpansionContext
25+
) throws -> [DeclSyntax] {
26+
return []
27+
}
28+
}

0 commit comments

Comments
 (0)