xamarin-macios icon indicating copy to clipboard operation
xamarin-macios copied to clipboard

[Xcode 12] WidgetKit reloadTimelines API is Swift only but really needs to be callable from C# host app

Open chamons opened this issue 5 years ago • 9 comments

As noted here the WidgetKit APIs are Swift only, which will make reloadTimelines not bindable without special measures.

This will make interacting with Widgets written in Swift extra painful, as you won't be able to request data reloads.

chamons avatar Jul 28 '20 14:07 chamons

One approach that Rolf came up with off the top of his head to consider is:

  • Build one swift file that exposes the API to C
  • Embed it in libxamarin
  • Create a managed API that p/invokes into it.

Extending our build to build swift on all platforms may be a tad tricky, but doable.

chamons avatar Jul 28 '20 14:07 chamons

+1 missing reloadTimelines will make new widgets implementation really annoying.

wojciech-kulik avatar Oct 03 '20 17:10 wojciech-kulik

See https://stackoverflow.com/questions/64185669/how-to-access-widgetcenter-from-widgetkit-in-xamarin-ios for work arounds.

t9mike avatar Feb 13 '21 17:02 t9mike

@t9mike I'm not sure if you noticed but this question on StackOverflow was created by me 😂 Btw. I've already implemented and published new version with widgets (and Apple Watch app manually added to xcarchive) ;) Here is the result: https://wojciechkulik.pl/smog-polska

wojciech-kulik avatar Feb 13 '21 22:02 wojciech-kulik

Oh I know! But just in case someone stumbles upon this issue but not the SO question. Thanks so much for your paving the way. Your app looks slick!

I have finally got to the point with my project that I have completed porting my core engine to Swift, created widgets, and new Apple Watch app (dumping old C# version).

t9mike avatar Feb 13 '21 23:02 t9mike

no updates here? Any plans to support that?

uwe-neuronation avatar Oct 15 '21 13:10 uwe-neuronation

This is still very much needed, thanks!

mnxamdev avatar Mar 15 '22 21:03 mnxamdev

Any updates ? Still very needed, thanks!

JeroenBer avatar Apr 17 '22 14:04 JeroenBer

While not a full solution to the general problem, the prototype in https://github.com/xamarin/xamarin-macios/issues/15315 can solve this specific problem, and I have a full sample which uses it.

Check it out!

chamons avatar Jun 21 '22 20:06 chamons