0

Environment:
Windows 10 Home, 21H2
VS Version 17.3.0 Preview 1.1

I have followed these steps to get to this error:

  • Create a new VS project
  • Select .NET MAUI App
  • Choose a file location and leave everything else to default
  • Setting the project configuration file to this
<PropertyGroup>
    <TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
    <!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
    <!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
    <OutputType>Exe</OutputType>
    <RootNamespace>MauiApp1</RootNamespace>
    <UseMaui>true</UseMaui>
    <SingleProject>true</SingleProject>
    <ImplicitUsings>enable</ImplicitUsings>

    <!-- Display name -->
    <ApplicationTitle>MauiApp1</ApplicationTitle>

    <!-- App Identifier -->
    <ApplicationId>com.testapp.maui</ApplicationId>
    <ApplicationIdGuid>CE4B9160-2B17-4559-8E4C-EA410A9A7966</ApplicationIdGuid>

    <!-- Versions -->
    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
    <ApplicationVersion>1</ApplicationVersion>

    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
    <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
    <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
    <CodesignKey>‌Apple Distribution: My Name (xxxxxxx)</CodesignKey>
    <CodesignProvision>Apple Provisioning</CodesignProvision>


    <ArchiveOnBuild>true</ArchiveOnBuild>
    <TcpPort>58181</TcpPort>
    <ServerAddress>xxxxx</ServerAddress>
    <ServerUser>xxxxx</ServerUser>
    <ServerPassword>xxxxx</ServerPassword>
    <_DotNetRootRemoteDirectory>/Users/xxxxx/Library/Caches/Xamarin/XMA/SDKs/dotnet/</_DotNetRootRemoteDirectory>

</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-ios|AnyCPU'">
  <BuildIpa>True</BuildIpa>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-ios|AnyCPU'">
  <BuildIpa>True</BuildIpa>
</PropertyGroup>

<ItemGroup>
    <!-- App Icon -->
    <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

    <!-- Splash Screen -->
    <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

    <!-- Images -->
    <MauiImage Include="Resources\Images\*" />
    <MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

    <!-- Custom Fonts -->
    <MauiFont Include="Resources\Fonts\*" />

    <!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
    <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
  • Connect to the build Mac

  • Test run on Windows as Windows app, successful.

  • Run this command

    dotnet publish -f:net6.0-ios -c:Release

Error

iOS code signing key '?Apple Distribution: My Name (xxxxxx)' not found in keychain.

  • I've also tried doing a Release build through VS GUI (Right click on Solution -> Rebuild), then I get this error:

Code signing must be enabled to create an Xcode archive.

Previous to that

Also notice, there is a question mark in the error '?Apple Distribution: My Name (xxxxxx)', which I don't know where it's coming from.

Update:

I used this command to create a log file during the build

dotnet publish -f:net6.0-ios -c:Release /bl:msbuild.binlog

The logfile can be viewed with this tool: https://msbuildlog.com/

In this logfile, the error message does not have the question mark. So I guess the question mark is just a display error when writing the log message.

In the binlog then, it literally says this:

The certificate 'Apple Distribution: My Name (xxx)' does not match 'Apple Distribution: My Name (xxx)‌'.

I have checked character for character. It is exactly the same string.

I also have noticed, that it does download the certificates from the server, because I can see them listed in the binlog after the entry "DetectingSigningIdentity"

Chris
  • 305
  • 4
  • 19
  • My bet it has something to do with the question mark that is in front. That makes the names not match and hence it can't find it. Did you try to retype the value in the `CodesignKey` node? maybe some weird invisible character ended up in there? Remove the whole thing and type it out instead of copying it from somewhere – Gerald Versluis May 31 '22 at 07:39
  • After digging deeper with the binlog, it turns out that there is actually no question mark. I have summarized it in my recent update. But I also tried your suggestion, with the same result, except that then the question mark appears at the end of the string. – Chris May 31 '22 at 14:25
  • To me that confirms the theory that there is some hidden character there... Did you remove only the value between the tags? What if you remove the whole line, tags included and type it as a whole? – Gerald Versluis May 31 '22 at 14:50
  • @GeraldVersluis Wow! Thank you! It was indeed a hidden character. Never experienced something like this and I would have never guessed this. I documented everything in the answer. – Chris Jun 01 '22 at 00:22

1 Answers1

0

I figured it out, thanks to the last comment!

The string

<CodesignKey>‌Apple Distribution: My Name (xxx)</CodesignKey>

contains a hidden character. I can't reproduce this in this post, because the hidden characters get filtered out.

But it can be reproduced with a string to hex converter: https://online-toolz.com/tools/text-hex-convertor.php

Type in this hex code: 3ee2808c and it will produce this character "<". When you type 3e, it will produce the same character "<". The problem is when copy/pasted, hidden characters come with it.

To prove this you can simply copy/paste the "<" from the first product into the tool again.

Looking up the character "e2808c", it stands for a "Zero-width non-joiner"
https://en.wikipedia.org/wiki/Zero-width_non-joiner
https://www.fileformat.info/info/unicode/char/200c/index.htm

How this got into the string, I don't know. I also didn't know that there can be hidden characters in strings!

So then one of these hidden strings got into my CodesignKey tag, and it would not match anymore. Visual Studio pointed this out correctly with a question mark. But my interpretation of the error was wrong, because I didn't expect something to be there that I can not see....

Chris
  • 305
  • 4
  • 19
  • I just tested it again, and the hidden character was not filtered out this time! Maybe it will by the time you are reading this or on your computer it will show differently. If it is there, you can find it at position 13 (<) in the string. – Chris Jun 01 '22 at 00:16