iPhone/iTouch免99美刀真机调试

时间:2025-03-06 13:37:08

本文经本人验证,攻略来源于网上,由于多次转载原始出处不可靠,故无法对原作者进行链接引用,抱歉。

本文仅为记录流程,以备日后查询。本文版权所无,欢迎转载和拍砖。

测试环境:

XCode 4.0.2 + iTouch 4_iOS_4.3.3(已越狱)

(据说iTouch需要用Cydia安装AppSync for 4.0+)

以下为详细步骤:

1.确保XCode关闭。

2.「生成本机证书」

  2.1. 应用程序-> 实用工具->钥匙串访问

  2.2. 菜单:钥匙串访问->证书助理->创建证书 

  2.3. 输入证书名称:iPhone Developer(请原样输入,不要试图自己乱改名字),并选择覆盖默认值 ,其他默认

  2.4. 点击继续

  2.5. 序列号填1,有效期365(不要试图超过365),点击继续

  2.6. 输入电子邮件,随便乱填,比如xxxx@163.com(此电子邮件拥有者要红了) ,点击继续

  2.7. 2048\RSA,点击继续

  2.8. 保持默认(1级2级打钩,3级‘签名’打钩),点击继续

  2.9. 勾选代码签名,继续

  2.10.不勾选基本约束扩展,继续 

  2.11.默认(RFC822为上面填的邮箱地址),继续 

  2.12.默认(登录),继续 。至此证书创建完毕。

3.「XX XCode」

  3.1. 复制以下内容到文本编辑中,保存为xx.sh

?
#!/bin/bash
cd
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/
dd
if=iPhoneOS\
Build\ System\ Support of=working bs=500 count=255
printf
"\x8f\x2a\x00\x00" >>
working
dd
if=iPhoneOS\
Build\ System\ Support of=working bs=1 skip=127504 seek=127504
/bin/mv
-n iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.original
/bin/mv
working iPhoneOS\ Build\ System\ Support
chmod
a+x iPhoneOS\ Build\ System\ Support
mkdir
/Developer/iphoneentitlements30

  3.2. 在终端中执行该sh脚本

  3.3. Finder中打开/Developer/iphoneentitlements30文件夹,复制以下内容,保存为gen_entitlements.py

?
#!/usr/bin/env
python
import sys
import struct
if len(sys.argv)
!
= 3:
    print "Usage:
%s appname dest_file.xcent"
 % sys.argv[0]
    sys.exit(-1)
APPNAME
= sys.argv[1]
DEST
= sys.argv[2]
if not DEST.endswith('.xml')
and not DEST.endswith('.xcent'):
    print "Dest
must be .xml (for ldid) or .xcent (for codesign)"
    sys.exit(-1)
entitlements
= """
<?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>application-identifier</key>
    <string>%s</string>
    <key>get-task-allow</key>
    <true/>
</dict>
</plist>
""" % APPNAME
f
= open(DEST,'w')
if DEST.endswith('.xcent'):
    f.write("\xfa\xde\x71\x71")
    f.write(struct.pack('>L',
len(entitlements)
+ 8))
f.write(entitlements)
f.close()

  3.4.将该py文件属性修改为777:打开终端,cd /Developer/iphoneentitlements30回车,chmod 777 gen_entitlements.py回车

  至此,XCode XX完毕。

4.「  修改/Developer/Platforms/iPhoneOS.platform/Info.plist」

  4.1. 用文本编辑打开Info.plist,将以下内容加在第一个<dict>下面一行

?
<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>

  4.2. 搜索Info.plist中的 XCiPhoneOSCodeSignContext,全部替换为 XCCodeSignContext,保存plist

5.「修改你的工程」(你以后真机debug其他工程时,都需要对新工程进行以下操作)

  5.1. 用XCode打开你的项目,找到你项目的xxx-Info.plist文件,添加”SignerIdentity”项,其值为”Apple iPhone OS Application Signing”.保存。

  5.2. 找到你项目的Build Settings-Code Signing Identity,把Debug和Release下面的分支都删除,然后将Code Signing Identity的值改为iPhone Developer

  5.3.  Build Settings-Code Signing Entitlements的值改为xxx/Entitlements.plist。其中xxx是你的工程文件夹名。 Entitlements.plist这个文件目前还没有,下一步我们就要建立这个文件。

  5.4. 在你的工程目录,右键New File -> iPhone OS -> Code Signing -> Entitlements,新建一个“Entitlements.plist”,点Finish,然后打开此文件,里面只有一项:Can be debugged,将其Value改为YES,保存

6. 至此所有步骤完成,接下来就是连接你的iOS设备了。如果第一次连接,XCode还不认识你的设备,需要什么Collect一下信息之类。总之连接上后,你可以发现XCode的build scheme里面可以选择到你的iOS设备。然后直接debug即可。

Have Fun!