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.44k stars 508 forks source link

Porting Keyboard Extension from xamarin.ios to .net8 #21119

Open abbetch opened 2 weeks ago

abbetch commented 2 weeks ago

Apple platform

iOS

Framework version

net8.0-*

Affected platform version

VS 2022 17.11.1

Description

I have a Xamarin.iOS project that include a keyboard extension. (Custom keyboard written in with xamairn.ios).

A lot of the logic / business c# code is shared with an android version, and macos version, and a windows version.

Since the end of visual studio for mac and xamarin, we've been looking to port that project, and decided to upgrade to .net8 since it was mentioned that most xamarin.ios feature were integrated in it.

My issue is that I can't see any option to create a .net8 keyboard extension in visual studio. (I've tried on a windows machine, and the soon deprecated visual stuidio for mac, even on jetbrain's rider).

Is it currently possible to do ? Even by maybe twicking the csproj by hand ? or it's currently not supported ? If that's the case, is this feature planned ?

Here is a barebone example of a keyboard extension written in xamarin.ios ( https://github.com/Francis365/CustomKeyboard )

Steps to Reproduce

Did you find any workaround?

No response

Build logs

No response

rolfbjarne commented 2 weeks ago

Extension projects are supported just fine, but we haven't implemented any templates yet (this is a known issue we're working on).

There's not really much magic to extension projects in .NET either, you can create an app project from a template, and I believe only two changes are required to make it an extension project:

  1. Extension projects are library projects, so remove <OutputType>Exe</OutputType> from the csproj.
  2. Add the <IsAppExtension>true</IsAppExtension> property to the csproj.

Then you can migrate everything in your Xamarin extension project to the .NET extension project as if were a normal app project.

rolfbjarne commented 2 weeks ago

Closing since there's nothing actionable from our side that's not already filed elsewhere.

If you have any problems porting/creating an extension project, feel free to keep asking here or opening a new issue.

thefex commented 1 week ago

Just make sure you add

 <ProjectReference Include="..\ExtensionProject.csproj" >
      <IsAppExtension>True</IsAppExtension>
      <IsWatchExtension>False</IsWatchExtension>
    </ProjectReference>

in your Main app project - extensions are not included in .app/.ipa in my case when it's added in Extension project