ios-reverse-engineering-skill iOS Reverse & Tweak Engineering Suite

Recover Swift Symbols from a Stripped iOS Binary

An App Store build removes the symbol table. The binary keeps the type names, because the Objective-C runtime and the Swift runtime need those names at execution time. The recovery step mines that metadata and rebuilds an address to name index.

Get the skill Teardown first

Why the names survive the strip

SourceThe sectionThe content
Objective-C metadata__TEXT.__objc_classnameThe class names
Objective-C metadata__TEXT.__objc_methnameThe selector names
Objective-C metadata__DATA.__objc_selrefsThe pointers to the selectors
Swift reflection__TEXT.__swift5_reflstrThe field names
Swift reflection__TEXT.__swift5_typesThe type descriptors
Compiler__TEXT.__cstringEvery string literal

Run the recovery


bash scripts/recover-names.sh app-teardown/binary/main.arm64 app-teardown/names

The step writes the files below.

FileContent
objc-classes.tsvThe Objective-C class names
objc-methods.tsvThe class, the selector, and the address
swift-types.txtThe demangled Swift type names
swift-fields.txtThe field names from the reflection metadata
swift-symbols.txtThe demangled Swift symbols
mapping.tsvThe address, the name, and the kind
mapping.jsonThe same data as JSON
by_module/One file per module

The selector pointer chain

A method list holds a pointer to the selector. That pointer points into __objc_selrefs. That section holds a pointer to the selector string. The string lives in __objc_methname. The chain has two hops.


method list → __objc_selrefs → __objc_methname → the selector text

The Swift demangling

A Swift class that inherits from NSObject keeps an Objective-C name. The name holds the Swift mangling.

Mangled nameDemangled name
_TtC7AlDente9DebouncerAlDente.Debouncer
_TtCV7AlDente12KeyPressViewAlDente.KeyPressView
_TtP7AlDente13MyProtocolAlDente.MyProtocol

echo '_TtC7AlDente9Debouncer' | swift-demangle

The module name is the most valuable fact. The module name separates the first-party code from the third-party code.

Query the index


# Search a name
bash scripts/lookup-name.sh app-teardown/names LoginService

# Resolve an address
bash scripts/lookup-name.sh app-teardown/names --addr 0x10002d314

# List a module
bash scripts/lookup-name.sh app-teardown/names --module AlDente

# Search a source folder
bash scripts/lookup-name.sh app-teardown/names --grep 'login' ./sources

Real output from a stripped release build:


_TtC7AlDente32EnableHighPowerModeIntentHandler  handleEnableHighPowerMode:completion:  0x10002d314
TtC7AlDente9Debouncer  →  AlDente.Debouncer

Combine the index with Ghidra

The index turns FUN_00101234 into a real name inside the decompiler.

  1. Run the teardown with the --decompile option.
  2. Run recover-names.sh on the same slice.
  3. Read the address in the decompiler.
  4. Run lookup-name.sh --addr to get the name.
  5. Read the class with the recovered name.
  6. The limits