Daan
Daan

Reputation: 377

Xamarin iOS code signing key not found in keychain

I'm trying to debug my Xamarin.Forms application on a physical iPhone, from my windows machine.

When I try to deploy my application in Debug|iPhone, I get the following error:

iOS code signing key 'Apple Development: John Doe (5L4565FZ2L)' not found in keychain.

More details from the build output in Visual Studio:

2>Using "DetectSigningIdentity" task from assembly "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\..\iOS\Xamarin.iOS.Tasks.dll".
2>Task "DetectSigningIdentity"
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Started
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Initializing
2>  [xma]: Trying to get a Build Connection for Session '6b535ab5f3c9b550fa521b36f236660807d516f929527c4e1cb2a3ecca9ec40d': Xamarin.Messaging.Build.Client.BuildConnection.6b535ab5f3c9b550fa521b36f236660807d516f929527c4e1cb2a3ecca9ec40d, Lifetime: AppDomain
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Initialized
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - There's no available inputs to copy to the Mac
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9039262+01:00 - Serializing intputs
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9079268+01:00 - Executing
2>  [xma]: Starting remote task execution for 'Writeful.Mobile.iOS': Xamarin.iOS.Tasks.DetectSigningIdentity
2>  [xma]: Sending Request Xamarin.Messaging.Build.Contracts.ExecuteTaskMessage to topic xvs/build/execute-task/Writeful.Mobile.iOS/6b535ab002fDetectSigningIdentity
2>  [xma]: Received Response of Xamarin.Messaging.Build.Contracts.ExecuteTaskMessage to topic build6b535ab5f3c9b550fa521b36f236660807d516f929527c4e1cb2a3ecca9ec40d47080johndoe/+/xvs/build/execute-task/Writeful.Mobile.iOS/6b535ab002fDetectSigningIdentity
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9499278+01:00 - Logging messages
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error : iOS code signing key 'Apple Development: John Doe (5L4565FZ2L)' not found in keychain.
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error :         
2>  DetectSigningIdentity: 2022-02-06T17:49:30.9499278+01:00 - Finished
2>Done executing task "DetectSigningIdentity" -- FAILED.
2>Done building target "_DetectSigningIdentity" in project "Writeful.Mobile.iOS.csproj" -- FAILED.
2>
2>Build FAILED.
2>
2>"C:\Users\johndoe\source\repos\johndoe\writeful-app\Writeful.Mobile.iOS\Writeful.Mobile.iOS.csproj" (Build;BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;DebugSymbolsProjectOutputGroup;DebugSymbolsProjectOutputGroupDependencies;DocumentationProjectOutputGroup;DocumentationProjectOutputGroupDependencies;SatelliteDllsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;SGenFilesOutputGroup;SGenFilesOutputGroupDependencies target) (1) ->
2>(_DetectSigningIdentity target) -> 
2>  C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error : iOS code signing key 'Apple Development: John Doe (5L4565FZ2L)' not found in keychain.
2>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(1566,3): error :         
2>
2>    0 Warning(s)
2>    1 Error(s)
2>
2>Time Elapsed 00:00:01.23
========== Build: 1 succeeded, 1 failed, 21 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

I'm not sure which device is missing the signing key, but I assume it is the iPhone, since I installed the certificate on the Mac.

If this is the issue, how can I transfer the certificate to the iPhone? I already tried by deploying an empty app from Xcode on the Mac to the iPhone, but that didn't work.

Upvotes: 14

Views: 26123

Answers (7)

Niels
Niels

Reputation: 1716

Check if the name in your .csproj file matches the certificate name in KeyChain Access

In my case the certificate in .csproj was missingafewspaces:

  1. open key chain access
  2. Go to Login > My certificates
  3. Xamarin/MAUI will search for the exact name that is in you csproj file, so check if the name in your .csproj file matches exactly with the name in displayed in KeyChain Access

Upvotes: 0

Matias Masso
Matias Masso

Reputation: 2000

I'm using Maui, and in my case this error came followed by the sentence "Please enable automatic provisioning from the ios bundle signing page".
So right click your project on Solution Explorer, click on Properties, expand iOS node, and select "Bundle Signing".
Under "Scheme" caption you'll find a dropdown; change "Manual Provisioning" to "Automatic Provisioning" and you are done.

Upvotes: 3

nick66
nick66

Reputation: 97

Had a similar problem with same error but for an existing project. The provisioning profiles were new because of an expired certificate. But the new valid ones were in the keychain.

Anyway, what worked for me was to turn off Hot Restart in VS->Tools->Options->Xamarin->iOS settings

Seems like it was holding on to the old certificates somehow. The clue was they kept reappearing in the keychain after I deleted them when I reconnected.

May not help OP but may help others with similar problem.

Upvotes: 0

Alex Abreu
Alex Abreu

Reputation: 161

It took me a while to figure out this issue. I had to export the certificate from my mac to a .p12 file and import the certificate into VS > Tools > options > Xamarin > Apple accounts > View Details > Import certificate and then select the p12 file and import it into VS make sure it display Valid on the status column.

Upvotes: 15

MakeAndDevelop
MakeAndDevelop

Reputation: 116

You would have to install both the development certificate AND the development provisioning profile on your Mac.

The easiest way to do this is by following the following steps:

  1. Download and install Xcode, you have probably already done this.
  2. Login into Xcode with your apple developer account: Xcode -> Preferences -> Account, use the + sign the add a new account.
  3. Once logged in Xcode will give you the option to Download Manual Profiles in the same view, click this and Xcode will do as promised. This can be done for each account and development team.
  4. Happy debugging!

Note: In Xcode projects (*.xcworkspace, Native iOS, Flutter, etc.) The easiest option is to click your top level app project (in xcode) and under Signing & Capabilities check the [ ] Automatically Manage Signing option.

You can also manually download the certificate and provisioning profile(s) from AppStoreConnect. Once downloaded, double click the files to install the certificate and profile. This should work, however, in my experience this can result in duplicate profiles and other weird issues. When using Visual Studio for Mac these are sometimes resolved by restarting VS for Mac or your machine. If issues persist, look in the following folder: ~/Library/MobileDevice/Provisioning Profiles here your installed profiles are listed. Finder will show you a preview with details if you select a provisioning profile. Delete duplicate profiles usually helps, these have different file names but the same profile details.

Upvotes: 10

Krunal Bagadia
Krunal Bagadia

Reputation: 419

it might be VS issue. Please refer this official Link where issue is fixed. Please make sure you're using latest version. Check Here

Upvotes: 0

Amjad S.
Amjad S.

Reputation: 1241

You can workaround the issue by removing the flag from the debug builds in the .csproj file. Try to follow this link : Check

Upvotes: 1

Related Questions