Speeding up slow app install times when debugging on a real Apple Watch

Fast Compile ➡ Install ➡ Run times are essential for developer productivity, especially when learning a new SDK. Given how new WatchKit is and the sparse detail of the official documentation, the only real way to really understand the call patterns and behaviors of WatchOS and WatchKit is to write lots of sample code and trace or debug it.

One of the most maddening things is how long it takes to install an app to a real Watch. This was particularly frustrating lately for two reasons:

  1. The simulator, while helpful, sometimes has different bugs or behaviors from the Watch itself.
  2. Apple has not released an updated version of Xcode with a WatchOS 1.0.1 simulator, so testing new behaviors such as the change to WKInterfaceController didAppear() caching requires testing on a real Watch.

Let's take a journey to find the fastest way to get from building to having a debugger attached to the Watch app and save all of our sanity.

The most expensive part is installation, so we profiled modifying a few variables to see what made the biggest impact for install time of our app. We tested installing the app over Bluetooth and also forced app install over Wi-Fi, and also tried to see if having the Apple Watch App open, on the app detail and not asleep mattered. This was tested on Xcode 6.3.2, iOS 8.2 and WatchOS 1.0.1.

Time Wireless Apple Watch App
4:23 Bluetooth Background
3:37 Bluetooth Background
2:39 Bluetooth Background
2:00 Bluetooth Background
1:26 Bluetooth Foreground
1:12 Bluetooth Foreground
1:06 Wi-Fi Background
1:01 Wi-Fi Foreground
1:00 Wi-Fi Foreground
1:00 Wi-Fi Background

Bluetooth installs were faster if the Apple Watch App was in the foreground.

From our admittedly unscientific tests, we can draw two conclusions:

  1. Bluetooth installs seem to be significantly faster if the Apple Watch App is in the foreground
  2. Wi-Fi was fast in every test.

Due to the consistency of the Wi-Fi approach, I'll focus on that here.

Setup

Make sure that your Apple Watch is set up to use Wi-Fi.

  • The Apple Watch can only use 2.4 Ghz Wi-Fi networks, so if your Wi-Fi is 5 Ghz and you can't enable 2.4 Ghz, you're out of luck.
  • The phone will automatically share Wi-Fi credentials with your watch.
  • You can test if it is working by turning off Bluetooth on your phone, and seeing if you can still use Siri or make a phone call with your watch.

Make sure your Apple Watch is paired with your iPhone, and it's identifier has been added to your Devices section in Certificates, Identifiers & Profiles in developer.apple.com.

Fastest Build -> Install -> Run -> Debug Cycle

  1. Turn off Bluetooth on your phone. The fastest way is to swipe up control center and toggle it there. You'll get a dialog nagging you to turn it back onhit cancel. We do this first to make sure that the system doesn't accidentally start installing the app over Bluetooth. If you turn off Bluetooth after it began installing over Bluetooth, we've found it hard to convince the phone to continue installing over Wi-Fi. It seems to prefer the network type it began the install.
  2. Hit stop in Xcode until it greys out. We've had lots of problems with Xcode attached to different old processes that cause problems later on. We recommend ensuring you're in a clean state.
  3. Choose the iOS base scheme in Xcode, and your device. If you build and run the WatchKit Extension scheme here, Xcode will time out trying to attach while you're waiting for it to install on the Watch which is more dialogs for you to click on.
  4. Click the Xcode play button to begin build and installation to your phone.
  5. When the iOS App starts running, multitask back to the Apple Watch App, open the page for your App. While this doesn't seem to speed up Wi-Fi installs, the system seems to notice faster that it needs to install an updated watch app than when you aren't on this screen. Obviously, make sure Show App on Apple Watch is enabled.
  6. Your app should install to device in about 1 minute.
  7. Turn on Bluetooth. You can't launch or debug your app over Wi-Fi, so this must be done. Again, swiping up control center is the fastest way to toggle Bluetooth.
  8. Back in Xcode, press ⌘6 to open the Debug Navigator  
  9. Hit stop again, switch to the WatchKit Extension Scheme in Xcode. Now we're going to attach debugging.
  10. Hit play in Xcode, when it is ready, you'll see in Debug Navigator show the extension as "Waiting to Attach".
  11. Manually open the app on your watch, and you'll see Xcode magically attach to the process.

Phew. That's a lot of steps. But we got pretty fast at it while we were trying to debug issues in our Chairman Cow game with WatchOS 1.0.1, and it's better than waiting 4 minutes per build for the app to install.

This is the best method we found. What are your tips and tricks for efficient Build ➡ Run ➡ Debug on a real watch? Please tell us if you have found a better way!