xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.48k stars 514 forks source link

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

Open aritchie opened 8 months ago

aritchie commented 8 months ago

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: https://github.com/xamarin/xamarin-macios/issues/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 https://github.com/xamarin/xamarin-macios/issues/16417.

rolfbjarne commented 8 months ago

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.

rolfbjarne commented 8 months ago

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 commented 7 months ago

Adding a relevant link to the topic on how to do this, there is also this discussion on the topic as well https://github.com/dotnet/maui/discussions/1144

liejuntao001 commented 6 months ago

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 commented 3 months ago

@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