AI Instruments is a macOS app that analyzes an iOS .app bundle and produces an "Instruments-style" diagnostic report focused on:
- Memory leaks
- Swift concurrency safety
- Memory allocations
This repository also contains TestApp, an iOS app intentionally packed with issue patterns so you can validate and iterate on the analyzer.
AIInstruments/- main macOS analyzer app (SwiftUI)TestApp/- iOS app used as analysis input
AIInstruments performs static binary analysis of a provided .app bundle:
- Loads app metadata (
Info.plist, executable, linked frameworks). - Parses Mach-O binary data (including debug dylib slices when present).
- Runs three instrument analyzers:
LeaksAnalyzerConcurrencyAnalyzerAllocationsAnalyzer
- Aggregates findings into a report with:
- Severity-tagged issues
- Confidence values
- Per-instrument score
- Overall score and grade
The app supports drag-and-drop and file picker import for .app bundles and allows exporting a text report.
The current implementation is an intelligent, rule-based analyzer over symbols, selectors, strings, sections, and linked libraries extracted from Mach-O binaries.
It is not a runtime profiler replacement for Apple Instruments. Instead, it is a fast static analysis assistant that can highlight likely risk patterns before runtime testing.
Key modules:
Analysis/AnalysisEngine.swift- analysis pipeline orchestrationAnalysis/MachOParser.swift- Mach-O/fat binary parsingAnalysis/BinaryAnalyzer.swift- shared evidence and pattern helpersAnalysis/LeaksAnalyzer.swift- leak risk detectionAnalysis/ConcurrencyAnalyzer.swift- Swift concurrency risk detectionAnalysis/AllocationsAnalyzer.swift- allocation and memory footprint risksModels/- issue/result/report domain modelsDI/- dependency injection with Factory (FactoryKit)
TestApp is a companion iOS app that intentionally demonstrates problematic patterns from the same three categories:
- Memory leak demos (delegates, closures, notifications, timers, circular refs)
- Concurrency demos (non-Sendable, detached tasks, mixed models, unsafe continuations)
- Allocation demos (image loading, data buffers, collection growth, string churn, file I/O)
Use it to generate realistic .app inputs and verify whether AIInstruments reports expected findings.
- Build
TestAppfor iOS Simulator in Debug. - Locate the built
TestApp.appproduct. - Launch
AIInstruments(macOS app). - Drop
TestApp.appinto AIInstruments. - Review issues and scores for Leaks, Swift Concurrency, and Allocations.
- Export report if needed.
From Xcode:
- Open
TestApp/TestApp.xcodeproj - Select a Simulator destination
- Build (
Cmd+B) - In Products, right-click
TestApp.app-> "Show in Finder"
From command line (example):
cd TestApp
xcodebuild -project "TestApp.xcodeproj" -scheme "TestApp" -configuration Debug -destination "platform=iOS Simulator,name=iPhone 16"Then find the app under DerivedData Build/Products/Debug-iphonesimulator/TestApp.app.
- Open
AIInstruments/AIInstruments.xcodeproj - Run the
AIInstrumentsscheme on macOS - Import a
.appbundle via drag-and-drop or "Browse Files"
AIInstruments includes unit tests for parser, analyzers, models, and analysis engine under AIInstruments/AIInstrumentsTests/.
Run from command line:
cd AIInstruments
xcodebuild test -project "AIInstruments.xcodeproj" -scheme "AIInstruments" -destination "platform=macOS" -only-testing:AIInstrumentsTests- Input format:
.appbundles (no.iparequired). - Analysis quality depends on symbol/string availability in the binary.
- Encrypted App Store binaries are not analyzable until decrypted.
- Findings are risk indicators, not guaranteed runtime bugs.
I'm always open to receiving feedback and contribution to my project so please feel free to open Pull Requests, raise Issues or reach out to me on X https://x.com/dammarkowski. Thanks!