There are multiple reasons for the need of remote debugging. In this case I needed to connect an iPhone to a Windows PC :/ and debug it simultaneously.
- Jailbroken Device (iOS 8.4) running ssh (see http://www.taig.com/en/ for the current jailbreak)
- A mac with Xcode
Attaching the Debugger to the iOS Device
This Tutorial is split up into multiple smaler steps starting with step 1:
At first you need to mount the DeveloperDiskImage.dmg for the current iOS version, in this case 8.4. To do so type in the Terminal:
hdiutil attach /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/8.4\ \(12H141\)/DeveloperDiskImage.dmg
Your screen should then look like this:
Copy the debugserver to your preferred directory
cd ~/Documents mkdir remotedebug cd remotedebug cp /Volumes/DeveloperDiskImage/usr/bin/debugserver .
(After copying the debugserver to your local storage you can unmount the DeveloperDiskImage via
hdiutil detach /Volumes/DeveloperDiskImage/)
You need to code sign the debugserver and for this you need an entitlements file. The file can be created by doing the following:
Then copy the following lines into the terminal window:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.springboard.debugapplications</key> <true/> <key>run-unsigned-code</key> <true/> <key>get-task-allow</key> <true/> <key>task_for_pid-allow</key> <true/> </dict> </plist>
Press ctrl + o (ctrl and o), then return and strg + x to exit.
To make sure everything worked well, type
cat entitlements.plist and your terminal screen should look like this:
You now need to resign the debugserver binary with the newly created entitlements file:
codesign -s - --entitlements entitlements.plist -f debugserver
Make sure that ssh is installed on your jailbreaked device. (If not: Open Cydia on the device and look for the user guide "OpenSSH Access How-To")
Then copy the newly singed debugserver to your device. You can find the IP Address of the device in the info tab of the currently connected wifi.
scp debugserver root@[insert IP Address]:/var/root
If asked, type yes into the console as seen in the screenshot. (The standard root password is "alpine")
You now need to start the debug server. For this connect to your device using ssh:
ssh root@[insert IP Address]
Then start the Application you want to debug and attach the debugger.
./debugserver *:1234 -a "Twitter"
Now the debugserver is running and is waiting for connections.
Start lldb on your computer with the following commands:
When lldb is started, connect it to the debugserver:
platform select remote-ios
process connect connect://[insert IP Address]:1234
You are now successfully connected to the remote debug session! Pressing
c resumes the process. For lldb commands check :
And for further reading: