一、生成证书
参考 http://blog.csdn.net/zhanglei5415/archive/2011/03/01/6214634.aspx
二 执行如下命令
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
cd /Developer/iphoneentitlements30
curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt
mv gen_entitlements.txt gen_entitlements.py
chmod 777 gen_entitlements.py
./gen_entitlements.py
三修改”/Developer/Platforms/iPhoneOS.platform/Info.plist”文件
1,共两处需要添加以下内容
<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>
2,然后将该文件中所有的”XCiPhoneOSCodeSignContext”替换为”XCCodeSignContext”,即去掉中间的”iPhoneOS” 。
添加修改后的文件如下:
<?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>AdditionalInfo</key>
<dict>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>DTCompiler</key>
<string>$(GCC_VERSION)</string>
<key>DTPlatformBuild</key>
<string>$(PLATFORM_PRODUCT_BUILD_VERSION)</string>
<key>DTPlatformName</key>
<string>iphoneos</string>
<key>DTPlatformVersion</key>
<string>4.2 Seed 2</string>
<key>DTSDKName</key>
<string>$(SDK_NAME)</string>
<key>DTXcode</key>
<string>$(XCODE_VERSION_ACTUAL)</string>
<key>DTXcodeBuild</key>
<string>$(XCODE_PRODUCT_BUILD_VERSION)</string>
<key>MinimumOSVersion</key>
<string>$(IPHONEOS_DEPLOYMENT_TARGET)</string>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.platform.iphoneos</string>
<key>CFBundleName</key>
<string>iOS platform</string>
<key>CFBundleShortVersionString</key>
<string>4.2</string>
<key>DefaultDebuggerSettings</key>
<dict>
<key>DataFormattersLocationPath</key>
<string>/Developer/usr/lib</string>
<key>DisableGuardMallocInDebugger</key>
<string>YES</string>
<key>DisableRestartInDebugger</key>
<string>YES</string>
<key>ProvidesAttachList</key>
<string>YES</string>
<key>RequiresDeviceForLaunch</key>
<string>YES</string>
<key>RunInDebugger</key>
<string>YES</string>
</dict>
<key>DefaultProperties</key>
<dict>
<key>ARCHS</key>
<string>armv6</string>
<key>CODE_SIGN_CONTEXT_CLASS</key>
<string>XCCodeSignContext</string>
<key>COMPRESS_PNG_FILES</key>
<string>YES</string>
<key>DEBUG_INFORMATION_FORMAT</key>
<string>dwarf-with-dsym</string>
<key>EMBEDDED_PROFILE_NAME</key>
<string>embedded.mobileprovision</string>
<key>INFOPLIST_OUTPUT_FORMAT</key>
<string>binary</string>
<key>NATIVE_ARCH</key>
<string>armv6</string>
<key>PLIST_FILE_OUTPUT_FORMAT</key>
<string>binary</string>
<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>
<key>SDKROOT</key>
<string>iphoneos4.2</string>
<key>STRINGS_FILE_OUTPUT_ENCODING</key>
<string>binary</string>
<key>TARGETED_DEVICE_FAMILY</key>
<string>1</string>
</dict>
<key>Description</key>
<string>iOS</string>
<key>FamilyIdentifier</key>
<string>iphoneos</string>
<key>FamilyName</key>
<string>iOS</string>
<key>Icon</key>
<string>iPhoneOS.icns</string>
<key>Identifier</key>
<string>com.apple.platform.iphoneos</string>
<key>Name</key>
<string>iphoneos</string>
<key>OverrideProperties</key>
<dict>
<key>CODE_SIGN_CONTEXT_CLASS</key>
<string>XCCodeSignContext</string>
<key>DEBUG_INFORMATION_FORMAT</key>
<string>dwarf-with-dsym</string>
<key>EMBEDDED_PROFILE_NAME</key>
<string>embedded.mobileprovision</string>
<key>SDKROOT</key>
<string>iphoneos4.2</string>
<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>
</dict>
<key>RuntimeRequirements</key>
<dict>
<key>Classes</key>
<array>
<string>XCCodeSignContext</string>
<string>XCProductPackagingUtilityCommandInvocation</string>
<string>DTDKProvisioningProfileController</string>
<string>XCiPhoneOSPlatformPlugin</string>
</array>
</dict>
<key>Type</key>
<string>Platform</string>
<key>Version</key>
<string>4.2</string>
</dict>
</plist>
四 修改另一个文件/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/SDKSettings.plist, 根据你当前的开发版本进入具体的版本号
目录,修改该文件中所有*_REQUIRED定义的行,把对应的值,即下一行的值改成NO, 保存退出。
五 删除 /Developer/Platforms/iPhoneOS.platform/DeviceSupport目录下与固定机器对应的设备目录
六 插入 itouch 启动xcode 让organizer 自动识别设备并添加自定义证书与目录 (要等一段时间)
看到绿灯成功
七 打开Xcode,打开你的项目,Project->>Edit Project Setting,选择”Build”页面,Configurations和Show都选择All,找到Code Signing Identity项,删除其
子项,并将”Code Signing Identity”赋值为”iPhone Developer”(其实是个选项),
选择Add User-Defined Setting, 加入两组数据(不知道是否有必要)
PROVISIONING_PROFILE_ALLOWED NO
PROVISIONING_PROFILE_REQUIRED NO
然后找到你项目的xxx-Info.plist文件,添加”SignerIdentity”项,其值为”Apple iPhone OS Application Signing”.保存。
八 建立 Entitlements.plist 文件 (重要),加入键值
get-task-allow boolean true
并将 build 里 Code Signing Entitlements 属性设为这个文件
至此大功告成,真机调试,或单步调试全无问题 。。。。