Watch app shared across multiple targets

You definitely cannot use one Watch app for multiple targets. Because the only factor Xcode uses trying to find out whether to include a Watch companion app to the bundle or not is a bundle ID of the Watch app. So there is a one-to-one relationship.

It follows you should duplicate each WatchOS app and extension target (changing only the bundle ID) for each iOS app target. But you still can share your code (including storyboards and assets) between targets by using Target Membership and it solves a problem of branded Watch apps either. Finally you get the minimum code duplication overhead.

Update: I see you're trying to duplicate a Watch target using a right click on a target and choosing a Duplicate option. It really doesn't work for some reason.

I just tried to clone a Watch target performing the following steps:

  1. File -> New -> Target -> WatchKit App.
  2. Specified the Embed in Companion Application the needed target.
  3. Added all files to the newly created target using the Target Membership option.

After that a project has been built and ran without any problem with a new Watch target.

This way you don't have to change the bundle ID manually - everything is created automatically and smoothly by Xcode.


You can use one target by creating Environment Variables to the projects and assigning in the plist files like images attached below.

Watch Extension ExtensionPlist

Also, you can do all the branding in the code depending on the bundle identifier by having helper like this

extension AppInfo {
    static var develop: Bool {
        return (self.CFBundleIdentifier?.contains("Dev") ?? false)
}