apple watch遇到的坑

1. table 不顯示的問題,


需要將之前 apple watch的target 刪除掉 文件夾刪除掉以後,按照正常的新建table的方式,進行顯示,注意自定義類的命名。以及關聯的問題。


2.debug watch 真機,真機不運行的問題


1.將watch 和 iPhone 中的程序全部刪除, 

2.將xcode 中 build 做clear 處理 

3 關閉xcode

4 重新啓動 iPhone

5 重新啓動 watch ,注意啓動後一定要選擇信任,否則還是不能夠正常運行。

6 打開xcode ,直到xcode能夠正常識別到watch

先把程序燒些到 iphone 上,運行watch的target ,







Make sure, the App on your Watch is not running (as BalestraPatrick described). Launch the app and hold the side button a few seconds to bring up the "Turn off your Watch" dialog. Hold the side button for another few seconds to close the app and to return to the Watch homescreen.
Make sure the iPhone is not locked.
Select the WatchKit App target and your real iPhone and run the project.
Running the Watch App resulted quite often in an error SPErrorInvalidBundleNoGizmoBinaryMessage. Re-starting Xcode and cleaning both the Watch App and the App target solved this.
If the build of the Watch App succeed there will be a short message in Xcode but nothing on your iPhone or Watch. If you have made changes to the Watch App it will take a few seconds to refresh the app on the Watch. This is indicated by the progress-circle overlay over the app icon. If you made no changes ore once the app has been transfered: Launch the watch app manually by tapping the icon. There will be no automatic launch.
In most cases Xcode will recognize the app launch and attach its debugger to it. This will allow to use breakpoints, inspect the code, etc.
In my case I whanted to inspect how the iPhone App handles the application:handleWatchKitExtensionRequest:reply: call when the app was not active before. This is important because this cannot be done using the simulator. If the app takes to long to handle the request the Watch will receive no valid response.


After following the steps described above Xcode is only attached the watch app and will not hold on breakpoints in the iPhone app code. To do this, one has to manually attach the Debugger to the iPhone app process that is started when the watch app sends its call.


To be able to attach the debugger I added a delay to the apps main function: [NSThread sleepForTimeInterval:5]:


Select function in Watch App that will start the call to the iPhone App
The iPhone App will be launched in background. The delays gives you 5 seconds to attach the debugger.
Choose Debug\Attach To Process\Likely Targes\Your iPhone Appin Xcode to attach the debugger.
After the 5 seconds delay the process will continue and you will be able to use breakpoints in your iPhone app code as well.
Do not forget do remove the delay code when you finished testing :-)
NOTE: You will not be able to see NSLog output (or any console output at all) from the iPhone App since attaching the debugger does NOT re-route the console output.


Happy testing with this awesome new Apple product :-P
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章