Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MacroExamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
BD3FE05C296611F200426C82 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
BD752BE4294D3BEC00D00A2E /* WarningMacro.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WarningMacro.swift; sourceTree = "<group>"; };
BD752BE6294D461B00D00A2E /* FontLiteralMacro.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontLiteralMacro.swift; sourceTree = "<group>"; };
BD841F81294CE1F600DA4D81 /* AddBlocker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddBlocker.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -131,6 +132,7 @@
BDF5AFD72947E5B000FA119B = {
isa = PBXGroup;
children = (
BD3FE05C296611F200426C82 /* README.md */,
BD841F80294CE14500DA4D81 /* MacroExamplesPlugin */,
BDF5AFE22947E5B000FA119B /* MacroExamples */,
BDFB14B32948484000708DA6 /* MacroExamplesPluginTest */,
Expand Down
14 changes: 4 additions & 10 deletions MacroExamplesPluginTest/MacroExamplesPluginTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ import _SwiftSyntaxMacros
import MacroExamplesPlugin
import XCTest

extension MacroSystem {
static var testSystem: MacroSystem {
var system = MacroSystem()
try! system.add(StringifyMacro.self, name: "stringify")
return system
}
}
var testMacros: [String: Macro.Type] = [
"stringify" : StringifyMacro.self,
]

final class MacroExamplesPluginTests: XCTestCase {
func testStringify() {
Expand All @@ -22,9 +18,7 @@ final class MacroExamplesPluginTests: XCTestCase {
var context = MacroExpansionContext(
moduleName: "MyModule", fileName: "test.swift"
)
let transformedSF = MacroSystem.testSystem.evaluateMacros(
node: sf, in: &context
)
let transformedSF = sf.expand(macros: testMacros, in: &context)
XCTAssertEqual(
transformedSF.description,
#"""
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ There is an active effort to introduce [macros](https://forums.swift.org/t/a-pos

Macros are an experimental feature, so you will need a custom Swift toolchain and some extra compiler flags. The Xcode project in this repository is a good starting point. To use it:

1. Download a [development snapshot](https://www.swift.org/download/#snapshots) of the compiler from Swift.org from December 15, 2022 or later. At present, we only have these working on macOS, but are working to get other platforms working with other build systems.
1. Download a [development snapshot](https://www.swift.org/download/#snapshots) of the compiler from Swift.org from January 1, 2022 or later. At present, we only have these working on macOS, but are working to get other platforms working with other build systems.
2. Open the project `MacroExamples.xcodeproj` in Xcode.
3. Go to the Xcode -> Toolchains menu and select the development toolchain you downloaded.
4. Make sure the `MacroExamples` scheme is selected, then build and run! If the first build fails, build again--there's something funky going on with the dependencies.
Expand Down