Swift Code Analysis

Structural analysis of Swift applications, iOS/macOS apps, server-side Swift, and SwiftUI architectures

What Axiom Refract Analyzes in Swift

Module and Framework Resolution

Resolves Swift import statements for frameworks, modules, and submodule imports. Maps dependencies between targets in Xcode projects and Swift Package Manager packages.

Protocol Conformance Graph

Maps protocol definitions, conformances, and extensions. Identifies where protocol-oriented programming creates structural coupling between modules through shared protocol requirements.

SwiftUI View Hierarchy

Traces SwiftUI view composition including body computed properties, ViewBuilder blocks, and environment/state object dependencies. Maps the view dependency graph for UI-driven applications.

Access Control Boundary Analysis

Analyzes Swift access control modifiers (open, public, internal, fileprivate, private) to identify architectural boundaries and detect access level violations that indicate coupling.

How It Works

Swift is parsed using a hand-hardened Tree-sitter grammar supporting Swift 5.5 through 5.10 syntax, including structured concurrency (async/await, actors, tasks), result builders, property wrappers, and macros. The parser handles Swift's complex generic system including associated types, conditional conformances, and opaque return types. Package.swift manifests are parsed for target dependency resolution in SPM-based projects.

Common Findings in Swift Codebases

Massive View Controller

iOS applications frequently develop view controllers with thousands of lines of code. Axiom identifies view controllers with high complexity and suggests decomposition into coordinators, view models, and child controllers.

Protocol Explosion

Swift's emphasis on protocol-oriented programming can lead to excessive protocol definitions that add indirection without architectural benefit. Axiom identifies protocols with only one conforming type.

Extension Scatter

Swift extensions allow adding functionality to types across multiple files, making it difficult to understand a type's complete interface. Axiom maps all extensions for each type and identifies scattered functionality.

Polyglot Support

Swift is one of 145+ languages Axiom Refract supports through Tree-sitter AST parsing. Swift analysis covers Package.swift, .xcodeproj (pbxproj), .xcworkspace, Podfile, Cartfile, and .swiftmodule references. Both SPM-based and CocoaPods/Carthage dependency management styles are supported. Your entire codebase is analyzed in a single scan — regardless of how many languages it contains.

Analyze your Swift codebase.