Search code examples
ios.net-coremauiprovisioning-profile

Visual Studio does not apply provisioning profile to MAUI iOS app in Debug mode


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?


Solution

  • After trying to deploy Microsoft's template app (that worked) and gradually adding features from the original app (a very painful process ...) I managed to find the problem: the entitlements. It looked like this (and that's how it should be for Release/Distribution builds):

    enter image description here

    but Debug builds should use the development APS environment. Apparently, that is not checked during compile/build time, only upon installation.