iosvisual-studioxamarincode-signingios-provisioning

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.


Solution

  • 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.