XCode-5-无证书真机调试iPhone
Posted
近来将开始写iOS的APP.一直都在模拟器上运行,觉得iphone没有派上用上。 又没有去申请apple的证书,那就发扬下DIY的精神先给自己发一个证书。能在iphone跑起先! 差不多时候再下手买一个证书!呵!
第1步:制作证书
打开:Finder->应用程序->实用工具 -> 钥匙串访问
单击:钥匙串访问-> 证书助理-> 创建证书...
第2步:修改XCode 5 的配置文件
2.1)修改SDKsettings.plist文件
查看下SDKs的是哪个版本的
ls /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
total 0
0 drwxr-xr-x 8 root wheel 272 10 27 09:33 iPhoneOS7.0.sdk
查了下是“iPhoneOS7.0.sdk”,那么直接进入他的目录
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk
[/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk] $
修改之前还是先备份下才是王道!
sudo cp SDKSettings.plist SDKSettings_bak.plist
复制到桌面修改。因为怕在SDKs的目录没有权限
sudo cp SDKSettings.plist ~/Desktop/SDKSettings.plist
打开 SDKSettings.plist
open ~/Desktop/SDKSettings.plist
修改SDKSettings.plist文件
CODE_SIGNING_REQUIRED的值改成NO
ENTITLEMENTS_REQUIRED的值改成NO
修改完成以后,返复制回SDKs的目录里头
sudo cp ~/Desktop/SDKSettings.plist SDKSettings.plist
2.2)修改Info.plist文件
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/
[/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform] $ ls -ls
total 168
0 drwxr-xr-x 5 root wheel 170 10 17 03:43 Developer
0 drwxr-xr-x 10 root wheel 340 10 27 09:33 DeviceSupport
0 -rw-r--r-- 1 root wheel 2011 10 5 11:58 IDEiOSTargetEditor.plist
0 -rw-r--r-- 1 root wheel 2403 10 5 11:58 Info.plist
168 -rw-r--r-- 1 root wheel 107919 10 5 11:58 iPhoneOS.icns
0 drwxr-xr-x 3 root wheel 102 10 27 09:33 usr
0 -rw-r--r-- 1 root wheel 479 10 27 09:31 version.plist
修改之前还是先备份下才是王道!
sudo cp Info.plist Info_bak.plist
复到桌面修改完成以后,回复制目录
sudo cp Info.plist ~/Desktop/Info.plist
sudo chmod a+w ~/Desktop/Info.plist
open ~/Desktop/Info.plist
右击-> Add Row,增加两项:
PROVISIONING_PROFILE_REQUIRED 值为 NO
PROVISIONING_PROFILE_ALLOWED 值为 NO
然后反复制回去
sudo cp ~/Desktop/Info.plist .
第3步:下载gen_entitlements.py文件
sudo mkdir /Applications/Xcode.app/Contents/Developer/iphoneentitlements
cd /Applications/Xcode.app/Contents/Developer/iphoneentitlements
sudo curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt
sudo mv gen_entitlements.txt gen_entitlements.py
sudo chmod 777 gen_entitlements.py
第4步:修改项目的属性
4.1)点击项目图标,找到"Build Settings"选项下的"Code Sign Identity",将其值全部改为"Don't Code Sign"
4.2)切换到Build Phases选项,点击右下角的Add Build Phase,然后单击Add Run Script,然后在Run Script中输入以下脚本:
export
CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
if [ "${PLATFORM_NAME}" =="iphoneos" ] || [ "${PLATFORM_NAME}" == "ipados"]; then
/Applications/Xcode.app/Contents/Developer/iphoneentitlements/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
搞定,重启下XCode
此文章 短链接: http://dlj.bz/YT7z1n