Friday, August 28, 2015

My Watch's HelloWorld

My post today is all about: Yes I did it!



Not just a HelloWorld on Watch
It's MY HelloWorld on MY Watch.

Okay, it may sounds very childish but hey it's not everyday you feel like a super hero having completed one of your geeky evening. Tonight, I defeated the dark forces: I managed to install watchOS2 beta5 on my watch, compiled, run and deployed my first Swift HelloWorld App on my watch.

I want to share with you my first experience and give you some tips and useful workarounds.

To start with, you need


In this tutorial we're going to show how to run an app on actual device.
You'll need:
  • Watch with WatchOS2 beta5 installed
  • iPhone with iOS9 beta5 installed
  • Xcode7 beta6

  • Start a new project


  • Open Xcode
  • Go to File -> New -> Project...


  • Choose watchOS -> iOS App with WatchKit App


  • Name your project MyHelloWorld, uncheck all boxes, we keep it simple :)
  • Go to MyHelloWorld WatchKit App folder, select Interface.storyboard
  • Add two labels, fill in with your personal Hello
  • Now time to run it!

    Run it on emulator


    Select your emulator either 30 or 42 mm.



    Run it on device


    You will need a bit of patience here, but here we go:



    If you run into...


    This is my troubleshooting notes. Hopefully you're done and all happen right, you can skip this paragraph and go to You're done section.

    Apple watch not paired


    The target is not reachable, Xcode is telling you "Watch not paired" or even no watch at all.
    Unplug, replug your iPhone. Go to Product -> Destination and select your iPhone + Watch.

    Spinning Wheel


    If you run into infinite spinning wheel on your watch, try this workarouand as described in this Apple Forum thread:

    Watch apps written with Swift code may not install to the Watch from the phone.
    Workaround: Add STRIP_BITCODE_FROM_COPIED_FILES=NO as a user-defined build setting on the iOS, watch, and extension targets (or just add it as a project default).


    Disappearance of your app on the watch


    You may run into a case where you can run your app from Xcode into you Watch but once you stop it, the app disappears from the watch. As a workaround you can install you iOS app as an archive. Follow the steps below:

  • build an ipa
    • go to Xcode Product->Archive
    • in the archive popuphit “Export…” button,
    • choose "Save for Dev Deployment"
    • select Export one app for all compatibles devices
    • all target, export
  • install ipa via iTune
    • go to list of all apps drag and drop the *.ipa
    • go to iPhone device, Apps, choose newly install app click intall and sync


    You're done


    You're ready to show off your first Watch app to your geeky friends... Or maybe wait a bit, start looking into WatchKit and see what you can code further ;)

    No comments:

    Post a Comment

    Note: Only a member of this blog may post a comment.