How fled-dev/mdmpatcher-enhanced works
1. Project shape
- This is a macOS desktop app built in Xcode using Swift + Cocoa/AppKit, with a Swift/C bridge for lower-level device work.
- The app is not a networked service; its architecture is centered on local USB device interaction and filesystem-based patch/restore preparation.
2. Primary user-facing layer
- AppDelegate.swift and ViewController.swift form the main application flow.
- The view controller owns the end-to-end workflow: detect a connected iOS device, display device metadata, enable the patch action, and surface errors/success notifications.
- ExtensionsShit.swift appears to hold UI helper behavior, mainly for alerts and user feedback.
3. USB/device discovery boundary
- USBDetection.swift is the monitoring layer that watches for USB events and filters for supported iOS devices.
- This is the first architectural boundary: the app moves from “no device present” to “eligible device detected” before any patching logic is allowed to run.
4. Low-level device communication
- libidevicefunctions.c/.h, idevicebackup2.c/.h, and iDeviceInfoFunctions.swift form the device-communication subsystem.
- These pieces rely on the libimobiledevice ecosystem and associated libraries to talk to iPhone/iPad services over USB.
- The app extracts device identity fields such as UDID, model/product type, serial number, IMEI when available, and build version to parameterize later file generation.
5. Bridge between Swift and C
- MDMPatcher-Bridging-Header.h is the interop boundary that exposes C APIs to the Swift UI layer.
- This separation is important: Swift handles UI/state, while C handles device sessions and restore mechanics.
6. Patch payload preparation
- The repo contains bundled artifacts such as extension1.pdf, extension2.pdf, libiMobileeDevice.dylib, and “clean” plist/archive templates.
- The architecture uses these as template inputs that are transformed per-device into a temporary working set.
- deobfuscation.swift and the related C utilities likely support the decoding/decryption/byte-processing stages described in the README.
7. File-processing and customization pipeline
- The patch flow is primarily local file generation:
- decrypt or unpack bundled templates,
- compute values from device metadata,
- rewrite Info.plist and Manifest.plist,
- prepare a backup-like directory structure.
- This is the second major boundary: the app moves from live device inspection to offline construction of restore inputs on disk.
8. Restore engine
- idevicebackup2.c is the restore orchestration layer.
- It coordinates the final device-side action using the prepared backup structure and communicates over the same USB/libimobiledevice stack.
- Architecturally, this is the execution phase that consumes the generated files and pushes them back to the connected device.
9. Supporting system libraries and bundled binaries
- The repository vendors many native dependencies: libimobiledevice, libusbmuxd, libplist, libirecovery, libcurl, libssl, libcrypto, libzip, libfragmentzip, libxpwntool, and others.
- These are not incidental; they are the runtime substrate for USB multiplexing, plist parsing, archive handling, and restore-related operations.
- The app is effectively a thin Swift GUI over a substantial native toolchain.
10. Data flow at a high level
- The main flow is:
1. detect a supported iOS device,
2. connect and read device metadata,
3. generate a device-specific working set from bundled templates,
4. invoke the restore engine over USB,
5. clean up temp artifacts and reset UI state.
- Errors can occur at any stage, and the app appears to funnel them back into the UI for user notification and retry.
11. Repository packaging
- This repo includes both source and prebuilt binaries, which suggests the app depends on a curated native stack rather than fetching dependencies at build time.
- The .xcodeproj, asset catalog, storyboard, and entitlements define a standard macOS app package, while the bundled dylibs/static archives define most of the non-UI functionality.
12. Important architectural boundary for diagrams
- The most important split is between:
- macOS UI/state management in Swift,
- native device/restore tooling in C and bundled libraries,
- local template/file transformation in between.
- An accurate diagram should show the app as a controller over USB-connected iOS devices, with a file-generation step in the middle and a restore step at the end, rather than as a client-server or cloud architecture.
Main entry points: ViewController.swift Main Flow · deobfuscation.swift Decode Stage · idevicebackup2.c Restore Engine · libidevicefunctions.c C Device API
Components 15
macOS UI
Swift/AppKit entry point, view state, and user feedback
- App Delegate · Launches the macOS app and hands control into the main UI flow
MDMPatcher/AppDelegate.swift - Main Flow · Owns device state, patch action enablement, and user-facing success/error handling
MDMPatcher/ViewController.swift - UI Alerts · Alert and feedback helpers used to surface outcomes to the user
MDMPatcher/ExtensionsShit.swift - App Package · Xcode project, storyboard, assets, and entitlements defining the macOS app bundle
MDMPatcher Universal.xcodeproj/project.pbxproj
Device bridge
USB detection and libimobiledevice-backed device communication
- USB Detection · Watches for USB events and filters for supported iOS devices
MDMPatcher/USBDetection.swift - Device Info · Reads UDID, product type, serial, IMEI, and build/version details
MDMPatcher/iDeviceInfoFunctions.swift - C Device API · C-side device communication and lower-level libimobiledevice calls
MDMPatcher/libidevicefunctions.c - Restore Engine · Coordinates backup/restore-style execution against the connected device
MDMPatcher/idevicebackup2.c - Bridge Header · Exposes C APIs to the Swift layer
MDMPatcher/MDMPatcher-Bridging-Header.h
File pipeline
Template decoding and per-device restore-package generation
- Templates · Clean plist/archive templates and packaged payload artifacts used as restore inputs
MDMPatcher/clean_archive.zip - Decode Stage · Byte-processing and decoding helpers used to unpack or normalize bundled payloads
deobfuscation.swift - Native Payload · Prebuilt local binary used by the patching workflow
MDMPatcher/libiMobileeDevice.dylib - Info Template · Device-specific Info.plist source for generated restore inputs
MDMPatcher/clean_info.plist - Manifest Template · Device-specific Manifest.plist source for generated restore inputs
MDMPatcher/clean_manifest.plist
Native stack
Bundled system libraries and prebuilt binaries used by the C bridge
- Vendor Stack · Curated libimobiledevice, usbmuxd, plist, restore, archive, crypto, and ZIP dependencies
Connections 19
- App Package → App Delegate: builds · Xcode builds the AppKit entry point and app bundle
- App Delegate → Main Flow: starts · Launch flow hands control to the main controller
- Main Flow → USB Detection: waits for device · The controller begins by listening for a supported USB-connected iOS device
- USB Detection → Device Info: selects target · Detected devices are filtered and then queried for identity metadata
- Main Flow → UI Alerts: reports · Success, errors, and prompts are surfaced through alert helpers
- Main Flow → Bridge Header: calls into C · Swift reaches the lower-level device and restore APIs through the bridge
- Bridge Header → C Device API: exposes · The bridging header makes the C device API available to Swift
- C Device API → Vendor Stack: uses · C device communication is implemented on top of bundled native libraries
- Device Info → C Device API: reads via · Metadata collection depends on the low-level USB/session layer
- Main Flow → Decode Stage: prepares payload · The main flow triggers local decoding and transformation work before restore
- Decode Stage → Templates: unpacks · Bundled artifacts are decoded or normalized into a device-specific working set
- Decode Stage → Info Template: writes · Info.plist content is rewritten from template data and device metadata
- Decode Stage → Manifest Template: writes · Manifest.plist content is rewritten for the target device
- Templates → Restore Engine: feeds · Prepared backup-like files are consumed by the restore engine
- Info Template → Restore Engine: consumed by · Generated Info.plist data is part of the restore input set
- Manifest Template → Restore Engine: consumed by · Generated Manifest.plist data is part of the restore input set
- Restore Engine → Vendor Stack: executes on · The restore phase runs over the same USB/libimobiledevice native substrate
- Native Payload → Decode Stage: supports · Bundled local binary participates in the patching or decoding pipeline
- Main Flow → Restore Engine: triggers · After preparation, the controller invokes the restore phase