本站電腦知識提供應用軟件知識,計算機網絡軟件知識,計算機系統工具知識,電腦配置知識,電腦故障排除和電腦常識大全,幫助您更好的學習電腦!不為別的,只因有共同的愛好,為軟件和互聯網發展出一分力!
第一步、制作證書 1)打開 Finder->應用程序->實用工具 -> 鑰匙串訪問 ; 2)單擊“鑰匙串訪問”選擇“證書”再選擇“創建證書”,證書名稱必須填寫為 iPhone Developer。
第二步、修改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文件,右擊--Add Row,增加兩項: PROVISIONING_PROFILE_ALLOWED 值為 NO PROVISIONING_PROFILE_REQUIRED 值為 NO
3)將上面Info.plist文件中的 "XCiPhoneOSCodeSignContext" 替換成"XCCodeSignContext"(共3處)
第三步、設置gen_entitlements.py腳本權限 注:如果你的電腦聯網了,那么執行1)的命令后會在相應的目錄自動創建iphoneentitlements文件夾及其下的gen_entitlements.py文件,如執行后沒有生成指定文件,請重復執行下面的命令或者換第二種方法,兩種生成腳本文件的方法任選一種。 1)在終端執行如下命令: mkdir /Applications/Xcode.app/Contents/Developer/iphoneentitlements cd /Applications/Xcode.app/Contents/Developer/iphoneentitlements curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt mv gen_entitlements.txt gen_entitlements.py sudo chmod 777 gen_entitlements.py 2)上面的命令執行成功之后,會在/Applications/Xcode.app/Contents/Developer/目錄下生成一個iphoneentitlements文件夾和其下的gen_entitlements.py文 件,如果你的電腦沒有聯網或者不能自動生成相關目錄文件,那么需要手動在相應的目錄創建指定的文件,隨后需要給gen_entitlements.py設 置權限。 gen_entitlements.py腳本文件的內容如下: #!/usr/bin/envpython import sys import struct if len(sys.argv)!= 3: print "Usage: %s appnamedest_file.xcent" % sys.argv[0] sys.exit(-1) APPNAME =sys.argv[1] DEST =sys.argv[2] if notDEST.endswith('.xml') and not DEST.endswith('.xcent'): print "Dest must be .xml (for ldid) or.xcent (for codesign)" sys.exit(-1) entitlements =""" application-identifier %s get-task-allow """% APPNAME f = open(DEST,'w') ifDEST.endswith('.xcent'): f.write("\xfa\xde\x71\x71") f.write(struct.pack('>L',len(entitlements) + 8)) f.write(entitlements) f.close() 在終端給gen_entitlements.py設置權限(可能會要你輸入密碼) sudo chmod 777 /Applications/Xcode.app/Contents/Developer/iphoneentitlements/gen_entitlements.py xcode5真機調試教程第四步、修改項目屬性 (每次新建項目都要執行) 1)點擊項目圖標,找到"BuildSettings"選項下的"Code Sign Identity",將其值全部改為"Don't Code Sign" 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
第五步、連接設備(iphone/ipad) 點XCode右上角的Organizer圖標,然后選中你的設備,在右邊窗口中點擊“Use for Development” 即可;
此時你的設備名稱旁邊應該顯示黃色的小燈,重新拔插數據線,Organizer中會出現一個進度條,等這個進度條跑完,小燈就會變成綠色,開發模式 已經啟用。
--測試真機調試: 創建一個Page-based Application工程,修改BuildSettings和Build Phases下面的相關配置(參考第四步) 1)選擇你的設備
2)隨便拖一個button,然后點擊運行(Run)
3)iphone運行效果截圖
xcode5真機調試教程就到這里咯~ 學習教程快速掌握從入門到精通的電腦知識 |
溫馨提示:喜歡本站的話,請收藏一下本站!