在采用真机免证书调试时,一切正常,在编译运行时出现该错误,导致无法attach到debug模式。
搜索了一些网页,最终尝试解决方案如下:
1. 首先在项目下新建一个plist文件。(这一步不是必须,因为下面会自动生成,仅供参考)
New->File->iOS->Resouce->Property List
创建文件Entitlements.plist
打开Entitlements.plist,在空白处右键Add Row增加属性Can be debugged,设为YES
2.创建一个gen_entitlements.py (这一步OK以后其他项目不需要再重复)
1) 在Terminal命令行下:
sudo mkdir /Applications/Xcode.app/Contents/Developer/iphoneentitlements
cd /Applications/Xcode.app/Contents/Developer/iphoneentitlements
2)新建gen_entitilements.py ,内容如下:
然后修改运行权限:
sudo chmod 777 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.配置Build Phrase (每个项目都需要配置一次)
1)选中项目后,点击Build Phases,在右下方看见Add Build Phase
2)选择Add Build Phase ,然后选择Run Script ,再在shell下的输入框中添加一下内容:
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
4. 配置Build Settings(每个项目需要配置)
修改targets的build setting属性值。
将Code Signing Entitlements 设为"Entitlements.plist"
将Code Signing Identity中Any iOS SDK设置为iphone Developer,其他则改为Don't Code Sign
以上3,4步骤对每个项目都需要重新设置一次,其他步骤则只需要配置一次。
关于Xcode 4.6 免证书真机调试的内容请搜索"Xcode 4.6 免证书"。