Articles

Reverse engineering iOS apps with AI: Mach-O, class-dump, Ghidra and Frida

How to analyse an iOS app you built or are authorized to assess with an AI agent — exporting the IPA, Mach-O basics, ObjC and Swift metadata with otool, nm and swift-demangle, Ghidra or Hopper, Frida and objection on a test device, and where models get Swift wrong.

· 11 min read

Yes — any AI agent that can run shell commands and read files can do serious work on an iOS app, as long as you give it the binary, the tools, and a device to test on. There is no single "iOS reversing AI." There's a workflow: unpack the app, have the agent read the Mach-O metadata and the decompiler output, and confirm what it concludes with Frida on a test device. The model is fast at the reading and the glue code. It is also reliably confused by Swift, and you need to know where.

This guide is for your own apps, or apps you're authorized to assess — a security review of your company's app, a client engagement with written scope, a mobile pentest under contract. It starts from a build you produced, so there's no decryption step. Pulling apps from the App Store, removing FairPlay encryption, or bypassing App Store protections is out of scope here, and in most places it's also a licence violation or worse. Your own debug or ad-hoc build gives you everything below, plus symbols that make the work far easier.

An iOS app review with an AI agent, step by stepExport an IPA of your own build from Xcode. Unzip it and review Info.plist, entitlements and the provisioning profile. Read the Mach-O metadata with otool, nm and swift-demangle. Load the binary in Ghidra or Hopper with the agent. Then confirm each finding at runtime with Frida or objection on a test device, and keep notes of what is confirmed.Export the IPAof your own buildUnzip: plist,entitlements, profileMach-O metadataotool, nm, demangleGhidra or Hopperwith the agentConfirm at runtimeFrida, objectionnotes.md:confirmed vs inferred
An iOS app review with an AI agent, step by step

What AI is good at on iOS

  • Mapping an app from its metadata. Objective-C keeps class, method and selector names in the binary; Swift keeps type names, field names and protocol conformances in its reflection sections. A model reading otool and nm output can sketch the app's architecture — networking layer, persistence, auth, analytics SDKs — before you open a disassembler.
  • Reading plist and entitlement files and flagging what matters: App Transport Security exceptions, custom URL schemes, associated domains, keychain groups.
  • Writing Frida and objection glue. ObjC hooks are formulaic, and models write them well.
  • Explaining ARM64 and objc_msgSend patterns in decompiled code, and turning a selector into the method it dispatches to.

Where it fails

  • Swift. Mangled symbols, value types passed in registers, witness tables, async functions split into pieces. More on this below; it's the biggest source of confident mistakes.
  • It trusts the decompiler. As with any binary, decompiled C is a hypothesis about the assembly.
  • It guesses at runtime behaviour. "This method is probably called at login" is a claim to check with a hook, not a finding.

The fix is the one from the general reversing workflow: make the agent cite addresses and symbols, and mark every claim confirmed or inferred.

Step 1: get the IPA of your own build

You need a build you control. In Xcode, Product → Archive, then in the Organizer choose Distribute App and a development or ad-hoc export. That writes an .ipa signed for your devices. From the command line, the same export is:

xcodebuild -scheme MyApp -configuration Release \
  -archivePath build/MyApp.xcarchive archive
xcodebuild -exportArchive -archivePath build/MyApp.xcarchive \
  -exportPath build/export -exportOptionsPlist ExportOptions.plist

ExportOptions.plist names the export method and team; Xcode writes one next to any IPA you export from the Organizer, so the easiest way to get a correct file is to export once by hand and reuse it. You don't strictly need the IPA for static work — the archive holds the app at MyApp.xcarchive/Products/Applications/MyApp.app — but the IPA is what you install on a test device.

Review two builds if you can: a Release build, which is what you ship and what an attacker would see, and a Debug build, which keeps more symbols and is easier to attach to. Findings should be confirmed against Release.

Step 2: unzip it and read the metadata files

An IPA is a zip archive. Work on a copy and record its hash:

mkdir work && cd work
shasum -a 256 ../MyApp.ipa > hashes.txt
unzip -q ../MyApp.ipa
ls Payload/MyApp.app

Inside Payload/MyApp.app you'll find the main executable (named after the app), Info.plist, embedded.mobileprovision, a Frameworks/ folder of embedded frameworks and Swift libraries, and PlugIns/ for app extensions — each extension is a separate binary worth reviewing.

Info.plist is usually a binary plist. plutil -p prints it readably on macOS:

plutil -p Payload/MyApp.app/Info.plist
codesign -d --entitlements - Payload/MyApp.app
security cms -D -i Payload/MyApp.app/embedded.mobileprovision

Hand those three outputs to the agent with a prompt that frames the review:

This is my app's Info.plist, its entitlements and its provisioning profile. List anything with security impact: ATS exceptions, URL schemes and what handles them, associated domains, keychain access groups, app groups, background modes, and any entitlement that shouldn't be in a Release build. Cite the key for each.

Things the review should catch:

  • NSAppTransportSecurity with NSAllowsArbitraryLoads or per-domain exceptions — cleartext HTTP left over from development.
  • CFBundleURLTypes — every custom URL scheme is an input another app can send. Each one needs its handler reviewed.
  • get-task-allow set to true in a Release build — it means a debugger can attach. It belongs in Debug only.
  • Associated domains, keychain groups and app groups — what data is shared and with whom.

OWASP's MASTG is the reference for what to check on iOS and how; MASVS gives you the list of requirements to report against.

Step 3: Mach-O basics, and the metadata an agent can read

The executable is a Mach-O file, often a single arm64 slice for a modern app. The commands below work with the stock Xcode command-line tools:

BIN=Payload/MyApp.app/MyApp
file "$BIN"
lipo -info "$BIN"                  # which architectures are in it
otool -L "$BIN"                    # linked libraries and frameworks
otool -l "$BIN" | grep -A4 LC_ENCRYPTION_INFO   # cryptid 0 for your own build
otool -l "$BIN" | grep sectname | sort -u        # the sections present

The section list tells you what kind of app it is. __objc_classlist and __objc_methname mean Objective-C classes and selectors; __swift5_types, __swift5_fieldmd, __swift5_proto and __swift5_reflstr mean Swift type metadata, field descriptors, protocol conformances and field names. That metadata is what makes iOS apps more readable than stripped C: even a symbol-stripped Release build keeps a lot of names.

Objective-C. class-dump reconstructs ObjC headers from the binary:

class-dump -H -o headers/ "$BIN"

-H writes header files, -o names the folder. The result is one header per class with every method and property, which is the single most useful thing to give an agent: it can grep headers/ for token, password, jailbreak, pinning or URLSession and tell you where to look. The original class-dump predates modern Swift and fails or produces partial output on Swift-heavy apps; maintained alternatives with Swift support exist (dsdump, and the class-dump command in the ipsw tool), so check what's current and what your binary needs.

Swift. Swift symbols are mangled. nm lists them, and swift-demangle (part of the Xcode toolchain) turns them into readable signatures:

nm "$BIN" | xcrun swift-demangle | grep -i -E 'auth|token|session' | head -50

A good agent prompt at this point:

Read headers/ and the demangled Swift symbols in symbols.txt. Map the app's modules: networking, auth, storage, analytics and third-party SDKs. For each, list the classes or types and the methods worth reading first, with the symbol names. Don't guess behaviour from names; mark everything as inferred until we've read the code.

Step 4: Ghidra or Hopper, with the agent

For the code itself, load the executable in a disassembler. Ghidra loads Mach-O natively and understands ObjC metadata; Hopper is a popular commercial alternative on macOS with good ObjC support. Either works with an agent.

With Ghidra, the headless workflow from the Ghidra, IDA and radare2 guide applies unchanged: dump the decompiled functions to a file the agent can grep, or connect an MCP server like GhidraMCP so the model can decompile, follow cross-references and rename as it goes. MCP servers for reverse engineering covers the options.

Two iOS-specific things to teach the agent up front, in your project instructions:

  • objc_msgSend is a dynamic dispatch, not a function. The method called is the selector in the second argument. Newer toolchains emit per-selector stubs (_objc_msgSend$methodName), which are easier to read; older binaries pass the selector reference explicitly. The agent should resolve each call to -[Class selector] before reasoning about it.
  • Retain/release is noise. ARC inserts objc_retain, objc_release, swift_retain and swift_release everywhere. Tell the model to ignore them unless the question is about memory.

Step 5: confirm at runtime with Frida and objection

Static analysis gives you hypotheses. A test device confirms them. Your options, all with your own app:

  • A jailbroken test device with frida-server installed. This is the most flexible, and it's what many mobile security teams keep for assessments.
  • A non-jailbroken device with a debug build that loads Frida Gadget. Frida's documentation covers embedding FridaGadget.dylib in an app and re-signing it with your own development certificate. Since it's your app, you can also link the gadget into a dedicated debug configuration in Xcode.
  • The Simulator for quick checks, with the caveat that it runs a simulator build, not the one you ship.

Then, with the device connected over USB:

frida-ps -Uai                                   # installed apps and their bundle IDs
frida-trace -U -f com.example.myapp -m "-[NSURLSession *]"
frida -U -f com.example.myapp -l hook.js

-U targets the USB device, -f spawns the app by bundle ID, and frida-trace -m traces ObjC methods matching a pattern. A minimal ObjC hook:

// hook.js — log every URL the app builds a request for
const NSURLRequest = ObjC.classes.NSURLRequest;
Interceptor.attach(NSURLRequest['+ requestWithURL:'].implementation, {
  onEnter(args) {
    console.log('request', new ObjC.Object(args[2]).toString());
  },
});

args[0] is the receiver and args[1] the selector, so the method's first real argument is args[2]. Frida 17 stopped bundling the ObjC bridge into the runtime for agents you build yourself with frida-compile; the frida command-line tool and frida-trace still provide it, so this script runs as shown.

objection wraps common Frida tasks in a REPL. Its documented iOS commands cover most of a first runtime pass:

ios info binary                     # PIE, ARC, stack canary, encryption
ios hooking list classes            # classes loaded at runtime
ios hooking watch class AuthManager # log calls on a class
ios keychain dump                   # what the app stores in the keychain
ios nsuserdefaults get              # what it stores in user defaults
ios cookies get
ios sslpinning disable              # on your own build, to proxy its traffic

Keychain and user-defaults dumps are where a lot of real findings come from: tokens in NSUserDefaults, secrets with the wrong keychain accessibility class. Once traffic is visible through a proxy, the mitmproxy guide covers mapping the API — for your own backend or one in scope.

Static claims are checked at runtime before they countThe agent reads the decompiled code and proposes a claim, for example that a method stores a token in user defaults. It writes a Frida hook and says what output it expects. You run the hook on the test device. If the output matches, the claim is marked confirmed in the notes; if not, it goes back to the agent as inferred and wrong.yesnoAgent: claim, hook,expected outputYou run the hookon the test deviceOutputmatches?Confirmedin notes.mdBack to the agent:re-read the code
Static claims are checked at runtime before they count

Where models get Swift wrong

This is worth its own section, because it's where an agent will waste the most of your time.

  • Calling convention. On arm64, Swift passes self in a dedicated register (x20) and errors in another (x21), not as the first ordinary argument. A model reading the decompiler's argument list will often attribute arguments to the wrong parameters. Ask it to check the Swift signature from swift-demangle against the registers used.
  • Value types in registers. Small structs and enums are passed and returned in several registers, so a function that "takes three arguments" in the decompiler may take one struct.
  • Strings. Swift's String is 16 bytes and stores short strings inline, with flag bits in the high byte. A model will misread a small-string constant as a pointer and go looking for data that isn't there.
  • Generics and protocols. Calls through witness tables and existential containers look like indirect calls into nowhere. The protocol conformance metadata in __swift5_proto tells you which type implements what; the model should use it rather than guessing.
  • async/await. An async function is compiled into several partial functions connected by continuations. The model will read one fragment and conclude the function "does nothing." Ask it to follow the resume functions.
  • Demangling in the decompiler. If your disassembler shows raw $s… symbols, demangle them before giving the output to the model. It can demangle some in its head, and gets the rest wrong.

The practical rule: for Swift code, have the agent state the demangled signature of every function it discusses, and confirm any argument-level claim with a Frida hook before building on it.

Keeping it honest and in scope

Put these in CAVEIRA.md, CLAUDE.md or AGENTS.md:

  • The app and build under review, its bundle ID, and the authorization (your own app, or the engagement and its scope).
  • Backend hosts that are in scope for traffic testing, and those that aren't — third-party SDK endpoints usually aren't.
  • Cite a symbol or address for every claim; mark each confirmed or inferred.
  • Never store or paste real user data, production tokens or signing keys into the conversation.

Which AI to use

Any agent with a shell works: Claude Code, Codex, OpenCode or caveira, plus the tools above on a Mac (most of the iOS toolchain — codesign, plutil, xcrun — is macOS-only; Ghidra, Frida and objection also run on Linux). Mainstream assistants handle a review of your own app well most of the time, but can refuse or hedge on jailbreak detection, pinning and anything near DRM, even when the app is yours (what to do about that).

caveira is a terminal and desktop agent whose backend serves uncensored, abliterated open-weight models, with a reverse-engineering skill that drives Ghidra headless and radare2, and MCP support for GhidraMCP or an IDA server. It won't lecture you about your own app. It also won't make Swift easier to read: the checks above apply whatever model you use. If you also ship on Android, the Android guide covers the same workflow with jadx, apktool and Frida.