您的位置:首页 > 移动开发 > IOS开发

ML OS X 10.8 + XCode4.4下实现无证书真机调试IOS5.1.1(亲测,附调试截图)

2012-12-18 20:22 876 查看
http://www.devdiv.com/iOS_iPhone-%E5%9B%BE%E6%96%87%E5%B9%B6%E8%8C%82_%E5%9C%A8ML_OS_X_10.8___XCode4.4%E4%B8%8B%E5%AE%9E%E7%8E%B0%E6%97%A0%E8%AF%81%E4%B9%A6%E7%9C%9F%E6%9C%BA%E8%B0%83%E8%AF%95IOS5.1.1_%E4%BA%B2%E6%B5%8B%EF%BC%8C%E9%99%84%E8%B0%83%E8%AF%95%E6%88%AA%E5%9B%BE_-thread-131478-1-2.html

第一步:制作证书

1)打开Finder->应用程序->实用工具->钥匙串访问

2)单击:"钥匙串访问"选择"证书"再选择"创建证书"过程如下图:



注意:证书名称必须填写为iPhoneDeveloper



















第二部:修改XCode配置文件

1)修改SDKsettings.plist文件

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk

打开该目录下的SDKSettings.plist文件,把CODE_SIGNING_REQUIRED和ENTITLEMENTS_REQUIRED的值改成NO



2)修改Info.plist文件

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/

用XCode打开该目录下的Info.plist文件,右击--AddRow,增加两项:

PROVISIONING_PROFILE_ALLOWED值为NO

PROVISIONING_PROFILE_REQUIRED值为NO



3)将上面Info.plist文件中的"XCiPhoneOSCodeSignContext"替换成"XCCodeSignContext"(共3处)



第三部:设置gen_entitlements.py脚本权限

1)文件的内容为:

/Applications/Xcode.app/Contents/Developer/iphoneentitlements/

01
#!/usr/bin/env
python
02
03
import
sys
04
import
struct
05
06
if
len(sys.argv)
!=3:
07
print
"Usage:
%sappnamedest_file.xcent"
%
sys.argv[0]
08
sys.
exit
(-1)
09
10
APPNAME
=sys.argv[1]
11
DEST
=sys.argv[2]
12
13
if
not
DEST.endswith(
'.xml'
)
andnotDEST.endswith(
'.xcent'
):
14
print
"Dest
mustbe.xml(forldid)or.xcent(forcodesign)"
15
sys.
exit
(-1)
16
17
entitlements
=
""
"
18
<?xml
version=
"1.0"
encoding=
"UTF-8"
?>
19
<!DOCTYPE
plistPUBLIC
"-//Apple//DTD
PLIST1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"
>
20
<plist
version=
"1.0"
>
21
<dict>
22
<key>application-identifier</key>
23
<string>%s</string>
24
<key>get-task-allow</key>
25
<
true
/>
26
</dict>
27
</plist>
28
""
"
%APPNAME
29
30
f
=open(DEST,
'w'
)
31
if
DEST.endswith(
'.xcent'
):
32
f.write(
"\xfa\xde\x71\x71"
)
33
f.write(
struct
.pack(
'>L'
,
len(entitlements)+8))
34
f.write(entitlements)
35
f.close()
2)在终端执行如下命令:

1
mkdir
/Applications/Xcode.app/Contents/Developer/iphoneentitlements
2
cd
/Applications/Xcode.app/Contents/Developer/iphoneentitlements
3
curl
-Ohttp:
//www.alexwhittemore.com/iphone/gen_entitlements.txt
4
mv
gen_entitlements.txtgen_entitlements.py
5
sudo
chmod777gen_entitlements.py
第四部:修改项目属性

1)点击项目图标,找到"BuildSettings"选项下的"CodeSignIdentity",将其值全部改为"Don'tCodeSign"



2)切换到BuildPhases选项,点击右下角的AddBuildPhase,然后单击AddRunScript,然后在RunScript中输入以下脚本:

1
export
CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
2
3
if
[
"${PLATFORM_NAME}"
==
"iphoneos"
]
||[
"${PLATFORM_NAME}"
==
"ipados"
];
then
4
5
/Applications/Xcode.app/Contents/Developer/iphoneentitlements/gen_entitlements.py
"my.company.${PROJECT_NAME}"
"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent"
;
6
7
codesign
-f-s
"iPhone
Developer"
--entitlements
"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent"
"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"
8
fi


第五部:连接设备(iphone/ipad)

点XCode右上角的Organizer图标,然后选中你的设备,在右边窗口中点击“UseforDevelopment”即可,此时你的设备名称旁边应该显示黄色的小灯,重新拔插数据线,Organizer中会出现一个进度条,等这个进度条跑完,小灯就会变成绿色,开发模式已经启用。





测试程序:

创建一个Page-basedApplication工程,修改BuildSettings和BuildPhases下面的相关配置(参考第四步)

1)选择你的设备



2)随便拖一个button,然后点击运行(Run)



3)我的iphone运行截图



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐