Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing with Jailbroken iPhone (Xcode)

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.

like image 406
hetelek Avatar asked May 31 '12 23:05

hetelek


People also ask

How do I install a side-loadable jailbreak app with Xcode?

When you’re ready to install your side-loadable jailbreak app with Xcode, then follow these steps: 1) Launch Xcode and click the Create a new Xcode project button in the startup window: 2) Make sure Single View App is selected in the next window, then click on the blue Next button:

How to run iOS apps on Xcode?

You need to plug the iPhone into the Mac that’s running Xcode. Then you must download the app to your Mac. When you select a real device in Xcode for testing, you need to add your Apple ID in the Accounts preferences of your project editor. If you’re part of the Apple Developer Program, you must register the device before running the app.

How do I add an Apple ID to my Xcode project?

When you select a real device in Xcode for testing, you need to add your Apple ID in the Accounts preferences of your project editor. If you’re part of the Apple Developer Program, you must register the device before running the app. You can also pair Xcode with iOS and tvOS apps if that device is on the same network as Xcode.

What is Xcode used for?

Xcode is an integrated development environment, better known as an IDE. It’s the official IDE for Apple that’s used to create, test, and debug apps for iPhone, iPad, Apple Watch, Mac, and Apple TV. Xcode is also great for team collaboration.


2 Answers

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!
like image 136
Andrew R. Avatar answered Sep 30 '22 17:09

Andrew R.


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.

like image 34
egregious Avatar answered Sep 30 '22 17:09

egregious