tree: 5d5c34e34c3d63c9243cc76cb768cbb70604c05d [path history] [tgz]
  1. plists/
  2. src/
  3. watchosSample.xcodeproj/
  4. build.gradle.kts
  5. project.yml
  6. README.md
  7. Storyboard.storyboard
kotlin-native/samples/watchos/README.md

watchOS sample

This example shows how to write watchOS UI applications in Kotlin, and run them on Apple Watch or simulator.

To build and run the sample do the following:

  1. Optional: install Kotlin Xcode plugin: https://github.com/touchlab/xcode-kotlin to have syntax highlighting and better debugging support.

  2. Open watchosSample.xcodeproj set development team to your own and make bundle ID unique in project setting. or

1a. Similarly modify bundleIdPrefix, DEVELOPMENT_TEAM and WKAppBundleIdentifier in project.yml and generate Xcode project with xcodegen (https://github.com/yonaskolb/XcodeGen/). Open generated watchosSample.xcodeproj with Xcode.

  1. Update property WKAppBundleIdentifier in plists/Ext/Info.plist with new ID of the watch application, if not regenerating project.

  2. Now build and run the application on a connected iPhone with paired Apple Watch or simulator.

Note that in this example we do not use storyboards, and instead create user interface components programmatically.

First run of application on the physical watch could be blocked, so run it from watch menu and explicitly confirm that developer is trusted.