Home > Software design >  Visual Studio does not apply provisioning profile to MAUI iOS app in Debug mode
Visual Studio does not apply provisioning profile to MAUI iOS app in Debug mode

Time:01-05

I have a Xamarin Forms app which I upgraded to .NET MAUI. Visual Studio recognizes the provisioning profile (if I open the dropdown I can see two valid ones, a wildcard and a specific one - I have already tried to manually select the right one here, but to no avail):

enter image description here

and the build output says it's recognized too:

Target _DetectSigningIdentity:
    Detected signing identity:
            
      Code Signing Key: "Apple Development: Gerwin de Groot (<some id>)" (<some other id>)
      Provisioning Profile: "Example (Debug)" (<some id>)
      Bundle Id: com.example.test
      App Id: <team id>.com.example.test

yet the deployment to the device fails:

 CopyingFile - Path: /Users/gerwin/Public/Projects/Example/bin/Debug/net6.0-ios/ios-arm64/Example.app/Poppins-MediumItalic.ttf
 CopyingFile - PercentComplete: 99%
 CreatingStagingDirectory - PercentComplete: 5%
 ExtractingPackage - PercentComplete: 15%
 InspectingPackage - PercentComplete: 20%
 PreflightingApplication - PercentComplete: 30%
 VerifyingApplication - PercentComplete: 40%
 ApplicationVerificationFailed: Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.0vKSvJ/extracted/Example.app : 0xe8008015 (A valid provisioning profile for this executable was not found.)
error MT1006: Could not install the application '/Users/gerwin/Public/Projects/Example/bin/Debug/net6.0-ios/ios-arm64/Example.app' on the device 'Gerwin's iPhone 11': AMDeviceSecureInstallApplicationBundle returned: 0xe8008015.


Application could not be uploaded to the device.

It's visible on the iPhone, but with a blank application icon and a cloud indicator:

enter image description here

and tapping it gives an error message

Unable To Install "Example"

This app cannot be installed because its integrity could not be verified.

I get similar results if I try to use the command line, e.g. with

dotnet build Example.csproj -c Debug -f net6.0-ios -t:Run -p:_DeviceName=<device UDID>

though surprisingly, Release mode (-c Release instead of -c Debug) works (from the Command line, not from Visual Studio itself because of another bug).

How can I fix this?

CodePudding user response:

This is gonna be long.

First, I had to enter my IOS account, being part of the team with admin (not sure if any lower will work) privileges.

This is done in tools > settings > xamarin > AppleAccounts. If you do not do it when the popup appears.

In the Project Properties, I had to select Automatic Provisioning and follow the steps.

Theoretically it should have:

  1. Add certificate.
  2. Add identifier.
  3. Add the device.
  4. Add profile.

However, it failed at step 2. So I had to go to: https://developer.apple.com/account/resources/identifiers/list

And add the identifier myself. If your app is com.mycompany.myapp, create it like: com.mycompany.*.

After that, I returned to the project properties, and tried the automatic provisioning again.

It detected, that step 1 and 2 were done, added the device, added the profile, signed and deployed it successfully.

(Keep in mind that debugging using hot reload does not handle app icon, splash screen, etc... so do not get surprised when you find them missing.)

Every now and then I have to do this procedure again, because when I update the VS or the .NET version, unexplained problems happen.

Good luck.

CodePudding user response:

Seems that your iOS device are not trusted.

There are several ways to provision the iOS device,

  1. Manual provisioning for iOS apps. When generating a new provisioning file, remember to also include the device you want to deploy. Actually i prefer using this way as it's more clear to me.

  2. Automatic provisioning for iOS apps.

You could check the document above and have a try.

Hope it works for you.

  • Related