首页 > 代码库 > Xcode5免证书真机调试
Xcode5免证书真机调试
接续前篇《Xcode 3.2.5免证书开发调试》,推出Xcode 5 免证书真机调试
更新于2014年3月15日,适用 Xcode5.1及iOS7.1
Xcode如果不破解,无法真机调试, 也无法编译真机Release文件,只有付费开通Apple开发者账号,才能申请真机调试。而Xcode进行破解后,结合越狱的iPhone或iPad, 即可免官方证书开发调试了!
生成本机证书
应用程序->其他->钥匙串访问
菜单:钥匙串访问->证书助理->创建证书, 然后按以下图片顺序操作即可:
Xcode 5免证书开发调试_打开创建证书菜单
Xcode 5免证书开发调试_输入证书名称iPhone Developer并选择覆盖默认值
Xcode 5免证书开发调试_确定继续
Xcode 5免证书开发调试_输入序列号有效期,有效期不要超过365天
Xcode 5免证书开发调试_输入电子邮件地址
Xcode 5免证书开发调试_输入密钥对信息
Xcode 5免证书开发调试_密钥使用扩展扩展选择:签名
Xcode 5免证书开发调试_已扩展的密钥使用扩展选择:代码签名
Xcode 5免证书开发调试_基本约束扩展不选择
Xcode 5免证书开发调试_主题备用名称扩展输入RFC822名称,填入邮箱名即可
Xcode 5免证书开发调试_用于该证书的位置选择钥匙串类型为登录
Xcode破解
保证Xcode处于关闭状态,命令行终端,复制粘贴下面的代码:
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/ sudo dd if=iPhoneOS\ Build\ System\ Support of=~/working bs=500 count=255 sudo chown mac:staff ~/working printf "\x8f\x2a\x00\x00" >> ~/working dd if=iPhoneOS\ Build\ System\ Support of=~/working bs=1 skip=127504 seek=127504 sudo /bin/mv -n iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.original sudo /bin/mv ~/working iPhoneOS\ Build\ System\ Support sudo chmod a+x iPhoneOS\ Build\ System\ Support sudo chown root:wheel iPhoneOS\ Build\ System\ Support
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 sudochmod777 gen_entitlements.py
#第6行这个位置,很多资料都说要执行gen_entitlements.py,但实际上在这里执行没有意义,在后面会提到在project设置中会设置执行gen_entitlements.py,生成项目专用的配置文件
修改SDKsettings.plist文件
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk (iPhoneOS后跟iOS版本号)
打开该目录下的SDKSettings.plist,文件会因为权限禁止修改,可命令行移动到用户目录,修改完成后再移动回原处)
1 sudo mv /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/SDKSettings.plist ~/
2 sudochownmac(你登陆系统的用户名,我的用户名是mac):staff ~/SDKSettings.plist
权限处理完成后,把CODE_SIGNING_REQUIRED和ENTITLEMENTS_REQUIRED的值改成NO
Xcode5免证书真机调试-修改SDKSettings.plist
修改保存后再将文件移回原处:
执行完脚本后修改"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Info.plist"文件(权限处理同上),做如下修改:
新增如下两项(告知项目编译无需证书):
Xcode5免证书真机调试-修改Info.plist
然后将该文件中所有的"XCiPhoneOSCodeSignContext"替换为"XCCodeSignContext",即去掉中间的"iPhoneOS" 。如果不进行此步,编译Device Release版本时會报错:
Xcode5免证书真机调试-修改Info.plist替换标识
修改项目属性 (每次新建项目都要执行)
A. 点击项目图标,找到"BuildSettings"选项下的"Code Sign Identity",将其值全部改为"Don‘t Code Sign"
Xcode5免证书真机调试-选择target
Xcode5免证书真机调试-修改Code Signing Identity
B. 切换到Build Phases选项,点击菜单Editor->Add Build Phase->Add Run Script 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
Xcode5免证书真机调试-Add Run Script Build Phase
Xcode5免证书真机调试-写入脚本
Xcode破解完成,或者更准确的讲,是配置完成!
Xcode真机调试
将 iPhone接入电脑,在Xcode的Window->Organizer中会检测到你的iPhone.查看iPhone和你的Xcode识别正常 后退出Organizer,选择编译环境为"iPhone Device-4.2|Release",点击"Build and Go",期间会出现让我们选择签名证书,点选"允许"后,等待你的iPad/iPhone屏幕点亮就ok了。
你的程序会自动下载到你的iPhone中,可以进行真机调试了
Xcode升级破解
如果是在原Xcode的版本上升级到5,并且之前已经破解过,那么只需要再做如下步骤即可:
在/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Info.plist中新增如下两项(告知项目编译无需证书):
PROVISIONING_PROFILE_ALLOWED = NO PROVISIONING_PROFILE_REQUIRED = NO
然后将该文件中所有的"XCiPhoneOSCodeSignContext"替换为"XCCodeSignContext",即去掉中间的"iPhoneOS" 。如果不进行此步,编译Device Release版本时會报错:
1Code Sign error: a valid provisioning profile matching the application‘s Identifier ‘com.yourcompany.xxxx‘ could not be foundXcode5免证书真机调试