You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Attaching a native watchOS app to a .NET app #20317
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.
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.
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.
@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
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.
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).
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.)
Activity
rolfbjarne commentedon Mar 18, 2024
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.
rolfbjarne commentedon Mar 18, 2024
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.
beeradmoore commentedon Apr 4, 2024
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
liejuntao001 commentedon May 20, 2024
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.
lilleydnSub commentedon Jul 26, 2024
@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
[-]Attaching a native watchOS app to a .NET 8 app[/-][+]Attaching a native watchOS app to a .NET app[/+]rolfbjarne commentedon Oct 20, 2026
This involves:
Design ideas:
XcodeProjectitem group to support watchOS projects. The main problem with theXcodeProjectitem 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)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, sayios-arm64+iossimulator-arm64and then the actual watch app inside).Kebechet commentedon Nov 22, 2026
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
AdditionalWatchOSAppadds.The ZIP format in
docs/native-watchos-apps-design.mdsuits us: we plan to have our SDK produce it (an unsigned.appper runtime identifier, plus entitlement templates such as HealthKit), so an iPhone project embeds the watchapp 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:
.csprojinput 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: asingle arm64 slice of .NET for iOS objects relabelled for watchOS and linked with
-target arm64-apple-watchos27(
arm64-apple-watchos27-simulatorfor the simulator), with no embedded dylibs or frameworks. ItsInfo.plisthasWKApplication; a companionbuild will set
WKCompanionAppBundleIdentifier(MT7211) instead of today'sWKWatchOnly.Can the ZIP layout be treated as a stable input that tools other than
CreateWatchOSAppZipproduce? The designdoc 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.)