Developing with Jailbroken iPhone (Xcode)

12,075

Solution 1

I'd try stepping through that tutorial again just to make sure you ran through the setup correctly. It seems like you can install the apps without issue, but the debugger just can't attach to the app after installation. If you really need the debugger, you could try instead opening the app on your device after installation, and then while it's running (and your device is plugged in to your Mac running Xcode), open Xcode and go to Product -> Attach to Process, and select your app from the list (if it isn't there, that's a whole other issue).

Also, try YllierDev's suggestion of enabling get-task-allow in your app's Entitlements file (if it doesn't have one, you can easily create one from your project's Info page in Xcode). Assuming you went through the tutorial correctly, that should help.

--

To enable the 'get-task-allow' in your app's Entitlements file with Xcode 4.3, do the following:

  1. Click your project under the project navigator, and select the name of your project under the 'Targets' column.
  2. Next, go to the summary tab, and under 'Entitlements', check 'Enable Entitlements'.
  3. Next, right click/command click the 'YOURAPP.entitlements' file under the project naviagtor, and select 'Show in Finder'.
  4. Open in in TextEdit, and add:

    <key>get-task-allow</key> <true/>

    right before </dict>.

  5. It should now debug and run fine!

Solution 2

There is a simple answer. The instructions on the iPhoneDevWiki are almost correct. After the write() to the temp file, you need to flush, else the tempfile is empty. Your ldid3.py should look like this:

#!/usr/bin/python
from sys import argv
from subprocess import call, check_call
from os.path import basename, splitext, join
from tempfile import NamedTemporaryFile

app = argv[-1]
obj_path = join(app, splitext(basename(app))[0])
if '-gta' not in argv:
    check_call(['/usr/local/bin/ldid', '-S', obj_path])
else:
    with NamedTemporaryFile() as f:
        f.write("""
            <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
            <plist version="1.0">
            <dict>
            <key>get-task-allow</key>
            <true/>
            </dict>
            </plist>\n""")
        f.flush()
        check_call(['/usr/local/bin/ldid', '-S' + f.name, obj_path])

I have debugging working this way with Xcode 4.3.3 and iOS 5.1.1. This works the way you intended and you'll never have to mess with entitlements for new projects.

Share:
12,075
hetelek
Author by

hetelek

I'm currently interested in machine learning (specifically, deep learning). I am seeking opportunities to apply deep learning at scale. Please contact me if you have lots of data that you or your company would like to utilize. I can build websites, mobile applications, and desktop applications. I have experience with many AWS services. I've successfully sold many software products, most related to iOS. I also enjoy staying up-to-date with the latest technologies and companies. I'm currently attending the Rochester Institute of Technology working towards a BS in software engineering, scheduled to graduate in 2020.

Updated on June 18, 2022

Comments

  • hetelek
    hetelek about 2 years

    I have a jailbroken iPhone 4S with the running iOS 5.1.1. I have Xcode 4.3.2, and I have been able to run my apps to my iPhone, but in a weird way. If I click the debug button on Xcode, it attempts to open the app on my jailbroken iPhone, but fails because it quickly opens and then closes. Even though this happens, if I open the app manually, by clicking it on the homescreen, it runs fine. That's pretty annoying. The most annoying thing is that this causes it to no longer allow debugging, as Xcode doesn't see that it is running.

    This is the output that it produces:

    error: failed to launch '/Users/hetelek/Library/Developer/Xcode/DerivedData/spyapp-flynnmpiqhjoilezvqsbaqdnkesn/Build/Products/Debug-iphoneos/spyapp.app/spyapp' -- failed to get the task for process 3741
    

    With the process ID changing every time of course.

    This is the tutorial I used for developing on my jailbroken iDevice: http://iphonedevwiki.net/index.php/Xcode#Developing_without_Provisioning_Profile

    Thanks for any help.