p-x9

A Swift macro that lets you write inline assembly and implement a Swift function.

10
0
89% credibility
Found May 31, 2026 at 10 stars -- GitGems finds repos before they trend. Get early access to the next one.
Sign Up Free
AI Analysis
Swift
AI Summary

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

1
💡 You discover a new way to write assembly in Swift

You find a Swift package that lets you write low-level machine code directly inside your Swift functions, assembled at build time.

2
📦 You add the package to your project

You include this library in your Swift project so you can use its special @Asm feature in your code.

3
🔧 You write your first assembly function

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.

4
⚙️ Your code gets compiled and assembled

When you build your project, the assembly source is turned into actual machine code bytes and embedded directly into your app's executable section.

5
🚀 You call your assembly function like any other function

Your Swift code calls the function normally, but underneath it jumps straight into your hand-written machine instructions.

🎉 Your low-level code runs safely in your app

Your assembly instructions are part of your signed app binary, so they work even in restricted environments like the App Store sandbox.

Sign up to see the full architecture

4 more

Sign Up Free

Star Growth

See how this repo grew from 10 to 10 stars Sign Up Free
Repurpose This Repo

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 Repurpose
AI-Generated Review

What is swift-asm-macro?

swift-asm-macro is a Swift macro that lets you embed hand-written assembly directly into your Swift functions. You write assembly as a string literal, and at compile time it gets assembled into machine code and embedded straight into your binary's code section. When you call the function, it jumps directly into your instructions with no runtime overhead. It uses the C calling convention, so you get C ABI argument passing without any runtime assembler or JIT complexity.

Why is it gaining traction?

The key selling point is compile-time assembly. Unlike JIT approaches, the code is baked into your signed binary at build time, which means it works in environments where allocating executable memory is forbidden (think App Store sandbox with W^X enforcement). The macro also gives you helpful compile-time diagnostics when your assembly is invalid or uses unsupported types, rather than crashing at runtime. It's a clean way to drop into assembly for performance-critical hot paths without leaving Swift entirely.

Who should use this?

Systems programmers writing performance-sensitive code on Apple platforms who need specific arm64 instructions that the compiler won't generate. Game developers, graphics engineers, or anyone working with SIMD intrinsics or hardware-specific sequences where Swift's optimizer isn't cooperating. This is not for general application development; if you need this, you already know why you need it.

Verdict

This is an experimental, early-stage project with only 10 stars and a credibility score of 0.9%. The implementation is thoughtful (good diagnostics, clean API), but x86_64 support is incomplete and the project lacks extensive documentation beyond the README. The Swift 6.3 requirement and Apple-platform-only stance are significant constraints. Worth watching if you're on the bleeding edge of Swift macro adoption, but not ready for production use without thorough validation.

Sign up to read the full AI review Sign Up Free

Similar repos coming soon.