Skip to content

MrSmart00/HelloWorldMacro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HelloWorldMacro

Static Badge Static Badge

Super Simple Swift Macro

SUMMARY

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.

USAGE

let value = #sayHelloWorld(with: "XXXX") // "Hello World XXXX!!!"

HOW TO TESTING FOR MACROS

1 Switch the scheme to MacroFeature スクリーンショット 2024-04-29 19 58 46
2 Select My Mac from the Macs as the device to run on スクリーンショット 2024-04-29 19 59 04
3 If set up this way, it is possible to test スクリーンショット 2024-04-29 19 59 10

https://forums.swift.org/t/cant-test-macros-on-xcode-15-1/69349

PRECONDITION

This time, the design involves adding macros within the app.
The project is separated into packages using the Swift Package Manager.

Structure

.
├── .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