Super Simple Swift Macro
To understand the structure of Swift Macros, I created a simple macro as a basic functionality.
This macro appends Hello World
to any input string.
let value = #sayHelloWorld(with: "XXXX") // "Hello World XXXX!!!"
1 | Switch the scheme to MacroFeature |
|
2 | Select My Mac from the Macs as the device to run on |
|
3 | If set up this way, it is possible to test |
https://forums.swift.org/t/cant-test-macros-on-xcode-15-1/69349
This time, the design involves adding macros within the app.
The project is separated into packages using the Swift Package Manager.
.
├── .gitignore
├── hello-world-macro.xcworkspace
├── HelloWorld
│ ├── Sandbox
│ │ ├── Assets.xcassets
│ │ ├── Preview Content
│ │ └── SandboxApp.swift
│ └── Sandbox.xcodeproj
├── LICENSE
├── packages
│ ├── Package.swift
│ ├── Sources
│ │ ├── App
│ │ ├── Macros
│ │ └── Plugins
│ └── Tests
│ └── PluginTests
└── README.md