In this watchOS 2 Tutorial I am going to be showing you how to create the standard and simple Hello World application. This will give you an overview to creating WatchKit targets and deploying your application to the watch device itself.
Add WatchKit target
I am going to assume that you know how to create a blank new Single View Application and also have basic knowledge of how Xcode is layed out. For example, the Storyboard and Object Library etc.. You do? Fantastic. Ok, so the next thing were going to do is to add a new target into this application so that we can use the watchOS. you do this by going to: File -> New -> Target.
This will bring up this dialogue:
On the left hand side, click Watch OS and then select WatchKit App. As you can see, just above that is the option for Apple Watch. Do not click this option. Click Next.
You will then be presented with another dialogue window. Enter these details:
- Product Name: WatchOSHelloWorldTutorial
- Organization Name: < co.uk.ios-blog > You can put anything here
Click Finish. That is the basics of your watchOS 2 Hello World application. If you build and run your app you will see something like:
watchOS 2 Hello World
So, This application doesn’t really say Hello World does it? Let’s fix that. What we’re going to do is to drag a UILabel from the object library, bottom right of Xcode onto your storyboard roughly in the center:
Great, Now you had added a UILabel to your watchOS 2 Hello World application. Let’s run this app so we can see the result. Now, Things are a little different to just running the app. We need to make sure that we select the WatchKit app target to run. We can chose any simulator.
We also need to make sure that we select Apple Watch as an External Device from your iOS Simulator Hardware Menu option:
That’s all folks, Re-Run your application and see your results.
Congratulations, you have just created your first watchOS 2 Application.
watchOS 2 Tutorials
Interested in going further? Check out all our WatchOS 2 Tutorials
To re-cap. In this watchOS 2 Hello World Tutorial I showed you how to create your first watchOS application. I covered how to add a new WatchKit App Target into your project and how to drag a UILabel onto your storyboard.
finally, I showed you how to run your watchOS application on both the simulator and the Apple Watch Device.
Please leave any comments below, I hope you enjoyed it.