docs-maui icon indicating copy to clipboard operation
docs-maui copied to clipboard

iOS service extensions

Open davidbritch opened this issue 1 year ago • 2 comments

Add content on how to add an iOS service extension to a MAUI project. This is supported, but there's no project template for it. Instead, it'll require re-using the project file created by the Xamarin.iOS template and porting it to MAUI.

https://github.com/dotnet/maui/issues/8299 https://github.com/dotnet/maui/discussions/3289

https://learn.microsoft.com/en-us/xamarin/ios/platform/extensions https://learn.microsoft.com/en-us/xamarin/ios/platform/extensions-with-xamarinforms

Update April 2023: While it's possible to get this working, iOS extensions have so many rough edges in .NET 6/7 that I'll hold off doc'ing this until some work's been performed in this area.

This item will add the templates: https://github.com/xamarin/xamarin-macios/issues/16127

davidbritch avatar Apr 17 '23 11:04 davidbritch

Is there any guidance available on creating an IPA build locally using the dotnet publish command? Specifically, considering that the iOS extension might require its own provisioning profile, how can the command address this limitation as it seems to allow only one provisioning profile with parameters: dotnet publish -f $(iOSVersion) -c $(BuildConfiguration) /p:ArchiveOnBuild=true /p:RuntimeIdentifier=ios-arm64 /p:EnableAssemblyILStripping=false /p:CodesignKey=$(CodesignKey) /p:CodesignProvision=$(CodesignProvision)

vikher avatar Jan 05 '24 23:01 vikher

@vikher Try to set build properties in the csproj file and let msbuild resolve it on the pipeline automatically:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net8.0-ios</TargetFrameworks>
    <UseMaui>true</UseMaui>
    <OutputType>Library</OutputType>
    <Nullable>disable</Nullable>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <ImplicitUsings>enable</ImplicitUsings>
    <PlatformTarget>ARM64</PlatformTarget>
    <MtouchDevice>iPhone</MtouchDevice>
    <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
    <ApplicationVersion>1</ApplicationVersion>
    <CodesignProvision>Automatic</CodesignProvision>
    <CodesignKey>iPhone Distribution</CodesignKey>
    <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
  </PropertyGroup>

  <PropertyGroup>
    <IsAppExtension>True</IsAppExtension>
    <IsWatchExtension>False</IsWatchExtension>
  </PropertyGroup>
</Project>

and in yaml:

    - task: CmdLine@2
      displayName: 'Build iOS App'
      inputs:
        script: >
          dotnet publish {ProjectName}.csproj -f "net8.0-ios" -c Release -v n
          /p:ArchiveOnBuild=true 

Of course, the app and extension profiles should be installed before archiving. If you get ditto.exe error - try to build extension app before main project.

skuzminov-softheme avatar Mar 07 '24 17:03 skuzminov-softheme