Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. iOS
  3. SwiftTrace

SwiftTrace

NOASSERTIONSwift

A Swift and Objective-C method tracing library that logs invocations and enables aspect-oriented programming via trampolines.

GitHubGitHub
748 stars53 forks0 contributors

What is SwiftTrace?

SwiftTrace is a dynamic tracing library for Swift and Objective-C that intercepts and logs method invocations at runtime. It helps developers debug, profile, and monitor application behavior by providing visibility into method calls without modifying source code. The library also supports aspect-oriented programming, allowing injection of custom logic before or after method execution.

Target Audience

iOS and macOS developers working on complex applications who need advanced debugging, performance profiling, or runtime behavior analysis tools. It's particularly useful for those dealing with dynamic dispatch, framework integration, or aspect-oriented programming in Swift.

Value Proposition

Developers choose SwiftTrace for its reliable trampoline-based interception (vs. traditional swizzling), comprehensive tracing capabilities across Swift and Objective-C, and unique features like aspect injection and object lifetime tracking not found in standard debugging tools.

Overview

Trace Swift and Objective-C method invocations

Use Cases

Best For

  • Debugging complex method invocation flows in mixed Swift/Objective-C codebases
  • Profiling performance bottlenecks by tracing method execution times
  • Implementing aspect-oriented programming patterns in iOS/macOS apps
  • Monitoring object allocation/deallocation patterns for memory management
  • Dynamic runtime analysis of third-party frameworks or system libraries
  • Adding logging or instrumentation to production apps without recompilation

Not Ideal For

  • Projects that heavily use Swift's final classes or whole module optimization, as SwiftTrace cannot intercept methods with direct dispatch.
  • Teams deploying to production where runtime overhead must be minimized, since trampolines introduce performance penalties.
  • Developers needing simple, out-of-the-box debugging tools without configuring linker flags or understanding low-level details.
  • Apps subject to strict App Store policies that may restrict dynamic code injection techniques.

Pros & Cons

Pros

Reliable Trampoline Interception

Uses assembly-language trampolines instead of traditional swizzling, ensuring accurate method interception with minimal performance impact, as highlighted in the philosophy section.

Comprehensive Tracing Flexibility

Allows tracing of entire bundles, specific classes, instances, or protocols via regex patterns, enabling targeted debugging and profiling without source code changes.

Aspect-Oriented Programming Support

Enables adding closures before or after method execution to modify arguments or return values, facilitating runtime behavior modifications for debugging or instrumentation.

Built-in Benchmarking and Tracking

Provides methods to measure invocation counts and elapsed times for performance analysis, plus object lifetime tracking for monitoring allocations and deallocations.

Cons

Limited to Non-Final Methods

Cannot trace final classes or methods compiled with whole module optimization, restricting use in performance-optimized codebases, as admitted in the README.

Complex Setup and Configuration

Requires adding linker flags like '-Xlinker -interposable' for full functionality and involves low-level details for aspect programming, such as understanding register allocation.

Invocation API Limitations

The dynamic invocation API only supports a limited set of argument types (e.g., Double, Float, Int) and requires manual type conformances for custom structs, adding complexity.

Frequently Asked Questions

Quick Stats

Stars748
Forks53
Contributors0
Open Issues1
Last commit2 months ago
CreatedSince 2016

Tags

#runtime-analysis#ios#aspect-oriented-programming#objective-c#method-tracing#profiling#swift#debugging#macos

Built With

a
assembly
O
Objective-C
S
Swift

Included in

iOS51.7k
Auto-fetched 9 hours ago

Related Projects

CocoaLumberjackCocoaLumberjack

A fast & simple, yet powerful & flexible logging framework for macOS, iOS, tvOS, watchOS and visionOS

Stars13,320
Forks2,272
Last commit27 days ago
PulsePulse

Network logger for Apple platforms

Stars7,195
Forks375
Last commit23 days ago
SwiftyBeaverSwiftyBeaver

Convenient & secure logging during development & release in Swift 4 & 5

Stars6,057
Forks493
Last commit1 year ago
NSLoggerNSLogger

A modern, flexible logging tool

Stars4,978
Forks563
Last commit3 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub