Create WatchKit extension XCode project structure

Hi,

At the moment I am using cmake for generating a xCode iOS project (using Qt for iOS framework) which is then used for creating an archive and for the app store submission. Now I want to add a WatchKit extension to the iOS app. This can be manually done in Xcode but each time cmake is run again, the xCode project is re-written and the WatchKit project structure must be manually re-created in xCode (which is a lot of work).

It is possible to compile for WatchOS (https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-or-watchos) but this does not create the appropriate xCode project structure.

Is it possible to generate a WatchOS/WatchKit extension structure (https://developer.apple.com/documentation/watchkit/setting_up_a_watchos_project?language=objc#3295999) using cmake?

Thanks,

There are XCODE_ATTRIBUTE_* properties that are available. But maybe this needs some dedicated support.

Yes, but to the best of my knowledge none of these work for this use case.

Knowing what to put into the Xcode project files would be a great help here. We’ve always had to reverse engineer the format.

Is it sufficient to post a project before and after adding the WatchKit extension (so that you can diff it)? Or do you need something else?

I suspect instructions for what boxes to poke in Xcode would also be helpful, but a before-and-after can’t hurt.

Attached is a sample project (https://bit.ly/41UY13r):

  • sampleqt: The Qt project with the CMakeLists.txt
  • build-sampleqt-Qt_6_5_0_for_iOS_BEFORE_WATCHKIT: The generated xCode project before adding WatchKit support.
  • build-sampleqt-Qt_6_5_0_for_iOS_AFTER_WATCHKIT: The generated xCode project after manually adding WatchKit support.

This video shows how to manually add WatchKit support to a xCode project: