p-x9 / swift-asm-macro
PublicA Swift macro that lets you write inline assembly and implement a Swift function.
swift-asm-macro is a Swift package that lets developers write inline assembly code directly in their Swift functions. The assembly is assembled into machine code at compile time and embedded into the executable's code section, allowing the function to jump directly into the hand-written instructions when called. It currently supports arm64 architecture and provides compile-time diagnostics for unsupported features.
How It Works
You find a Swift package that lets you write low-level machine code directly inside your Swift functions, assembled at build time.
You include this library in your Swift project so you can use its special @Asm feature in your code.
You attach the @Asm decorator to a top-level function, passing in a string of assembly instructions that will be assembled into real machine code.
When you build your project, the assembly source is turned into actual machine code bytes and embedded directly into your app's executable section.
Your Swift code calls the function normally, but underneath it jumps straight into your hand-written machine instructions.
Your assembly instructions are part of your signed app binary, so they work even in restricted environments like the App Store sandbox.
Star Growth
Repurpose is a Pro feature
Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.
Unlock RepurposeSimilar repos coming soon.