SwiftMacros
No description available
Install / Use
/learn @Aeastr/SwiftMacrosREADME
Overview
#Obfuscate— Compile-time string obfuscation to hide strings from static analysis#previewOnly— Execute code only when running in Xcode Previews#buildConfig— Different values for DEBUG vs RELEASE builds@PublicInit— Generate public memberwise initializer for structs
Installation
dependencies: [
.package(url: "https://github.com/Aeastr/SwiftMacros.git", from: "1.0.0")
]
import SwiftMacros
[!NOTE] Xcode will prompt you to trust macros from this package on first use. Click "Trust & Enable" to proceed.
Usage
#Obfuscate
Hide strings from static analysis tools (strings, hex editors, etc).
let secret = #Obfuscate("MySecretString")
With explicit method:
let secret = #Obfuscate("MySecretString", .xor) // default, best
let secret = #Obfuscate("MySecretString", .bitShift) // very good
let secret = #Obfuscate("MySecretString", .reversed) // good
let secret = #Obfuscate("MySecretString", .base64) // moderate
let secret = #Obfuscate("MySecretString", .bytes) // minimal
[!CAUTION] This is obfuscation, not encryption. It raises the bar from "trivial" to "annoying" — a determined attacker with a debugger will always win. Never use for API keys or secrets.
#previewOnly
Execute code only when running in Xcode Previews.
#previewOnly {
viewModel.loadMockData()
}
Expands to the ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" check.
#buildConfig
Different values based on build configuration.
let apiURL = #buildConfig(debug: "http://localhost:3000", release: "https://api.prod.com")
let timeout = #buildConfig(debug: 60, release: 10)
Expands to #if DEBUG / #else / #endif.
@PublicInit
Generate a public memberwise initializer for structs.
@PublicInit
public struct User {
let id: UUID
let name: String
var isActive: Bool = true
}
// Generates:
// public init(id: UUID, name: String, isActive: Bool = true) { ... }
Contributing
Contributions welcome. Please feel free to submit a Pull Request.
License
MIT. See LICENSE for details.
Related Skills
node-connect
341.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.4kCommit, push, and open a PR
