Skip to content

Attaching a native watchOS app to a .NET app #20317

Open

Description

@aritchie

With watchOS being officially removed since .NET 6, we now have to do native watchOS apps (not an issue).

There is still the ability to create app extensions and those work fine, but how do I link in a native watchOS app?

I've looked through Microsoft docs without any luck. I've found this issue: #10070 and from that an example app: https://github.com/vouksh/MauiWithWatchApps

Is there something more "official" in terms of how to accomplish this?

@dalexsoto

--

See #16417.

Activity

  1. rolfbjarne commented on Mar 18, 2024

    @rolfbjarne
    Member

    Is there something more "official" in terms of how to accomplish this?

    No, at the moment there's no official way to add a native watchOS app to a .NET project.

    We should figure out a way though; the example app you linked to seem to work by accident because we haven't removed the build logic to support watchOS apps yet (this is because most of the build code is shared between Xamarin.iOS and .NET, once we drop support for Xamarin.iOS we'll eventually want to remove non-.NET code).

    In any case you can use the method the sample app uses, we'll keep making that work until we implement a supported way of doing it.

  2. added this to the .NET 9 milestone on Mar 18, 2024
  3. added
    feature
    on Mar 18, 2024
  4. rolfbjarne commented on Mar 18, 2024

    @rolfbjarne
    Member

    I'm tentatively marking this for .NET 9, but it's likely it won't get done until later. IMHO this would make sense to implement when we remove watchOS logic in our code base, which we probably won't do until after .NET 9.

  5. beeradmoore commented on Apr 4, 2024

    @beeradmoore

    Adding a relevant link to the topic on how to do this, there is also this discussion on the topic as well dotnet/maui#1144

  6. liejuntao001 commented on May 20, 2024

    @liejuntao001

    Thanks for the demo project MauiWithWatchApps
    I tried it and it does bundle the native Watch app into the dotnet iOS app, but that's it.
    The watch app does not install automatically.
    I could manually install it from the Watch app, but the 2 apps (on watch and on iphone) don't talk to each other. The WCSession never bomes Reachable.
    Is it just me or same for others?
    Any suggestion to improve?

    Never mind. I figured out I have to add one line to the demo native watch app to initilate the WCSession.

  7. modified the milestones: .NET 9, .NET 10 on May 28, 2024
  8. lilleydnSub commented on Jul 26, 2024

    @lilleydnSub

    @liejuntao001 I have successfully added an app this way and used WCSession to send Data from the phone to the App. Althoiugh you probably figured out the issue already

  9. changed the title [-]Attaching a native watchOS app to a .NET 8 app[/-] [+]Attaching a native watchOS app to a .NET app[/+] on Sep 26, 2024
  10. modified the milestones: .NET 10, .NET 11 on Oct 22, 2025
  11. modified the milestones: .NET 11, .NET 12 on Jul 20, 2026
  12. rolfbjarne commented on Oct 20, 2026

    @rolfbjarne
    Member

    This involves:

    • Design a way to include a watchOS Xcode project into a .NET project.
    • Create a test:
      • A watchOS Xcode project
      • A .NET project that references that watchOS project
      • Build and verify the resulting .app includes the watchOS Xcode project. An important part is to get signing right, so also verify that the watchOS app is signed correctly.
    • Implement support for said design.
    • Remove leftover support code for when we/Xamarin supported watchOS.

    Design ideas:

    • Augment the existing XcodeProject item group to support watchOS projects. The main problem with the XcodeProject item group is that it's non-trivial to make it work when building from Windows (which it currently doesn't - Not able to build iOS binding library with XcodeProject items on Visual Studio (Windows) #23408)
    • Add a new item group, say AdditionalWatchOSApp, that specifies the path to either the Xcode project or the built watchOS app (or a zipped version, which is easy to support from Windows). One advantage with the Xcode project path is that we can built it for either simulator or device ourselves, while the built watchOS app would have to be specified differently in the csproj (or we can support pointing to a directory that contains architecture-specific directories, say ios-arm64 + iossimulator-arm64 and then the actual watch app inside).
  13. Kebechet commented on Nov 22, 2026

    @Kebechet
    Contributor

    Thanks for #27284, it covers our case too. A data point and one question.

    Our case: Watchious (https://github.com/Kebechet/Watchious) is a watch-only UI framework for .NET. The watch app is
    built from a .NET project: C# compiled by .NET for iOS with NativeAOT, linked into a SwiftUI host and relabelled for
    watchOS (the SDK that does this is in Kebechet/Watchious#6, under review). Phone messaging
    needs that watch app to ship inside the user's iPhone app (often a MAUI app) as its companion, which is exactly what
    AdditionalWatchOSApp adds.

    The ZIP format in docs/native-watchos-apps-design.md suits us: we plan to have our SDK produce it (an unsigned
    .app per runtime identifier, plus entitlement templates such as HealthKit), so an iPhone project embeds the watch
    app with one <AdditionalWatchOSApp Include="…/MyWatch.zip" /> line, on a Mac or on Windows with a paired Mac.
    Reading the PR settled two things for us:

    • A .csproj input is out of scope ("The watch app remains a native Xcode project"), so our SDK produces the ZIP.
    • ValidateExecutable (MT7214) checks each slice's platform and architecture, which our executable should pass: a
      single arm64 slice of .NET for iOS objects relabelled for watchOS and linked with -target arm64-apple-watchos27
      (arm64-apple-watchos27-simulator for the simulator), with no embedded dylibs or frameworks. Its Info.plist has WKApplication; a companion
      build will set WKCompanionAppBundleIdentifier (MT7211) instead of today's WKWatchOnly.

    Can the ZIP layout be treated as a stable input that tools other than CreateWatchOSAppZip produce? The design
    doc describes zipping the app with a Mac ZIP tool, while MT7210 says "Use CreateWatchOSAppZip to create the package".
    A note on whether the layout stays stable, and how a breaking change to it would be signalled, would let us rely on
    it.

    We're happy to test a build of the PR with a Watchious watch app embedded in a MAUI iPhone app. (The other half of
    our case, starting .NET for iOS from the watch app's own host, is #27422.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurewatchOS

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions