Caius Theory

Now with even more cowbell…

Stop HealthKit causing SIGABRT

You have some crazy idea for an iOS app that uses HealthKit so you fire up Xcode, create a new project & add the HealthKit entitlement. Follow the tutorial to request authorization from the HKHealthKitStore. Hit run to make sure the app compiles and find that it instantly crashes with a SIGABRT in AppDelegate.

Puzzled by this you go over the minimal amount of code you've added and pare it right down to just the HKHealthKitStore.requestAuthorization call which is still causing the SIGABRT as soon as the app tries to boot.

The missing piece of the puzzle is Info.plist needs a key adding to it for the HealthKit authorisation screen. The documentation helpfully forgets to mention this however. Here's some quick simple steps to fix it:

  1. Open Info.plist in Xcode
  2. Click the (+) at the top to add a new key/value to the file
  3. Enter "Privacy - Health Share Usage Description" for the key
  4. Enter a useful message to the user explaining why they should allow access to their healthkit data for your app for the value
  5. Run your app and see the HealthKit authorisation sheet appear

NB: if you want to update/write any data to healthkit, you'll need to add the "Privacy - Health Update Usage Description" key with a description as well.

Solve volume down button not working on iPhone 5

I noticed this morning that my volume down button (-) wasn't working on my iPhone 5 running iOS 7. Pushing the physical button in didn't change the volume. The volume up button increased the volume successfully still.

As is my normal first step debugging iPhone weirdness, I rebooted the phone by turning it off, leaving it off for a few seconds, then booting it back up with the power button. Once powered off and on in this way, the volume down key still didn't decrease the volume.

Fearing a physical button issue at this point, I turned to google for suggestions on what else to try. Running across this thread on Apple's discussion forums, I tried out the solution in there.

  1. Open "Settings"
  2. Scroll down and tap on "General"
  3. Tap on "Accessibility"
  4. Scroll down to the bottom and tap on "AssistiveTouch"
  5. Tap the toggle for AssistiveTouch to turn it on, and you should see a little icon appear on screen (white circle contained in a dark grey rounded square)
  6. Tap the AssistiveTouch icon (was in the top left corner on screen for me)
  7. Tap on "Device"
  8. Tap "Volume Down" a bunch of times and you should see the volume being turned down
  9. Tap outside the AssistiveTouch dialog to close it
  10. Try pushing the physical Volume Down button

In my case, following these steps made my physical volume down button start working again. Makes me wonder if the solution author on the apple discussion thread is right, in that this is a software issue and forcing a volume down action through the on-screen interface makes it remember that there's a physical button to respond to as well.

Either way, I can stop deafening myself whenever I receive a notification now!