ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 탈옥한 device에 올린 어플 디버깅 하기!
    iPhone/i폰 어플 개발 2011. 7. 15. 04:45
    후훗... 탈옥한 device에 개발자 등록없이 어플 올리기.... 에서 끝이 아니다. 

    debug를 하기 위해서, debug모드로 device에 올리면, device에 intall이 끝난 후 어플 실행되기도 전에, 콘솔 창에 

    The program being debugged is not being run..

    이따구 에러가 뜬다. 기기에서 수행은 잘 되지만, xcode에서는 전혀 인식하지 못하는 것이다. 

    만료된 provisioning file을 삭제하라던지, 재부팅을 하라던지, 갖가지 방법을 다 써봤지만 안된다. 


    testing environment:
           iPhone 4 with iOS 4.2.1
           XCode 3.2.6 with SDK 4.3
           Snow Leopard 10.6.8


    해결책(원본) : 걍 따라하면 됨 -_-ㅎ ▼



    PROBLEM: I still can't get iPhone 4 working. If you have one, please try it and help me out! UPDATE: Found the cause of the problem to be certain status bar libraries installed alongside other apps. I'm not sure why they cause the problem, but see full notes at the bottom of the post.

    The Goal: As usual, we want to be able to click "build and go" in Xcode and get the app we're working on to load to the phone and start up. Also, we want to be able to debug from within Xcode itself. After all, Xcode is cool, and terminal+makefiles+gcc+gdb is lame.

    Abstract: The plan remains unchanged from the 3.x method. In fact, you commenters practically wrote this one for me. This time we're going to tell Xcode that it doesn't need to codesign for iPhoneOS targets, then we're going to tell it don'tcodesign for iPhoneOS targets, then we're going to tell it, well, actually, codesign but do it using our script, not your built in method.

    The Process: With Xcode closed and your device unplugged from the computer,

    1. If you've done this step before for previous guides, you may ignore it. You'll need a code signing identity in order to sign code to run on the device. Normally, this would be issued by Apple, but later on we'll break the signature check so you can make a "Self-Signing Identity" using this guide from apple (coral). Note that you should name the identity “iPhone Developer” EXACTLY to avoid having to change a bunch of the steps below.
    2. On your jailbroken iPhone, install the app AppSync. Add the source http://cydia.hackulo.us to cydia. You'll get a warning about pirating software: this patch, by virtue of breaking Apple's DRM so that we can install our own app, also enables us to install cracked App Store apps. Don't do that. It's immoral, fails to support legitimate developers who should be rewarded for their effort, and perhaps above all, pirating $2 cell phone apps is just ultra lame. But since our purposes are not nefarious, dismiss the warning. From this repo, install the package AppSync for OS 4.0, and for good measure, reboot the device.
    3. Make some Plist adjustments, starting with SDKSettings.plist:
      1. cd /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk
      2. sudo cp SDKSettings.plist SDKSettings.plist.orig
      3. sudo vi SDKSettings.plist

      Find

      1. <key>CODE_SIGNING_REQUIRED</key>
      2. <string>YES</string>

      and change YES to NO
      then find

      1. <key>ENTITLEMENTS_REQUIRED</key>
      2. <string>YES</string>

      and change YES to NO again. HINT: in vi, you can type the '/' key in order to "Cmd-F"

    4. Now, move on to the platform Info.plist
      1. cd /Developer/Platforms/iPhoneOS.platform/
      2. sudo cp Info.plist Info.plist.orig
      3. sudo vi Info.plist

      Two times, the following appears:

      1. <key>CODE_SIGN_CONTEXT_CLASS</key>
      2. <string>XCiPhoneOSCodeSignContext</string>

      Find each occurrence and replace the block

      1. <string>XCiPhoneOSCodeSignContext</string>

      with

      1. <string>XCCodeSignContext</string>
    5. And now the real bad boy, some binary patching of Xcode:
      1. cd ~/Desktop
      2. vi script

      hit the "i" key and copy/paste:

      1. #!/bin/bash
      2. cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/
      3. dd if=iPhoneOS\ Build\ System\ Support of=working bs=500 count=255
      4. printf "\xc3\x26\x00\x00" >> working
      5. /bin/mv -n iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.original
      6. /bin/mv working iPhoneOS\ Build\ System\ Support
      7. chmod a+x iPhoneOS\ Build\ System\ Support

      type the keys, in order: ":" "x" "enter"

      1. chmod 777 script
      2. ./script

      If it works right, you should see something like

      1. $ ./script
      2. 223+1 records in
      3. 223+1 records out
      4. 111648 bytes transferred in 0.002678 secs (41692099 bytes/sec)
    6. At this point, you're done telling Xcode it doesn't need to codesign. Now, we tell it don't codesign:

    7. With a new project open and ready to go (presumably you want to debug this one, though once you change these settings once, they'll persist from project to project) open Project>Edit Project Settings (from the menu). Click on the "Build" tab.
      Find "Code Signing Identity" and its child "Any iPhoneOS Device" in the list, and set both to the entry "don't code sign"

      Screen shot 2010-01-11 at 1.05.42 AM

      Should look like this

      Now you've told Xcode "don't codesign."






    8. Almost done: time to tell Xcode "well, actually you should codesign."
      1. mkdir /Developer/iphoneentitlements401
      2. cd /Developer/iphoneentitlements401
      3. mv gen_entitlements.txt gen_entitlements.py
      4. chmod 777 gen_entitlements.py
    9. Just hit cancel.

      And finally, to link the device and computer. Plug your iPhone in and open Xcode. Open Window>Organizer. Select the device from the list on the left hand side, and click "Use for development." You'll be prompted for a provisioning website login, click cancel. It's there to make legitimate provisioning easier, but doesn't make illegitimate not-provisioning more difficult.

    Now you're good to go! But there's just one last thing. You have to do this last part for every new project you make.Go to the menu Project > New Build Phase > New Run Script Build Phase. In the window, copy/paste this:

    1. export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
    2. if [ "${PLATFORM_NAME}" == "iphoneos" ]; then
    3. /Developer/iphoneentitlements401/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent";
    4. codesign -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"
    5. fi


    That will call the script you just downloaded in step 5 to sign our app with a fake signature. This is important only for debugging. If you do build and go otherwise, the app will load to the phone, but the app will fail to launch and you'll get:

    Error from debugger: The program being debugged is not being run

    That should do it. Take all those steps and you should be home free for JBDev without paying $99.



     

    새 프로젝트를 생성했을때나 (재부팅 후에는) 반드시 다음의 단계를 새로이 수행 해줘야 한다. 

     
    스크립트를 다시 지정해줘야 한다.

    export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate

    if [ "${PLATFORM_NAME}" == "iphoneos" ]; then

    /Developer/iphoneentitlements401/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent";

    codesign -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"

    fi

     
     
     Project Setting에서 Code Signing Identity 를 Don't Code Sign 으로 바꿔준다.

     

     
Designed by Tistory.