MAUI raises on iOS MT1045

I wrote already a post about how to deploy a MAUI application on a real device but, recently, very often the process raises on iOS the error MT1045. The error I get is this one

error MT1045: Failed to execute 'devicectl': 'devicectl -j /var/folders/dm/bwmxpbzn6bvdsyy73c_b453w0000gn/T/tmpoVlvWe.tmp device install app --device "Enrico???s Test iPhone" /Users/enrico/Library/Caches/Xamarin/mtbs/builds/LanguageInUse/1fa03704bb15e35c6f47a701d9d92131e3e0740198296a93338bb3c829bc9cf7/bin/Debug/net8.0-ios/ios-arm64/device-builds/iphone13.1-17.4.1/LanguageInUse.app' returned the exit code 1.

So, I have my app in Visual Studio, I connect my iMac to it and I deploy the application on the real device. What you can see is that the app is started to be deploy, you can see the progress but suddenly, the installation returns an error. In the following video you have an example.

Start the checks

First, I have to check if the device is in Developer mode. I’m pretty sure it is because I deploy on it already but just in case.

  1. Developer mode is not enabled on the iOS device. See Apple – Enable Developer Mode.
  2. There is another app installed with the same bundle identifier. To solve this, delete the conflicting app or change your app’s bundle identifier.
  3. Certificate/provisioning profile related issues.
  4. If you don’t trust the phone from your Mac, you can also try this step. If so, please ignore this: Open Mac -> Xcode -> Settings -> Devices and Simulators. Xcode will pair your device.

Download Profiles

Now, every time you change the configuration of your app in the Apple Developer Portal, you have to download the new certificates for you app.

Although I don’t think I have changed anything, I tried to download the Profiles of my Apple account both in Visual Studio and in Xcode. In Visual Studio, open Tools > Options and then search for the option Apple Account.

Then, click on you developer account and click View Details. A new window will open for the Details of your account. Click on Download All Profiles.

Download iOS certificates from Visual Studio - MAUI raises on iOS MT1045
Download iOS certificates from Visual Studio

Similarly, in Xcode. Open Xcode, on the menu click on Settings. Under Accounts, click on Download Manual Profiles.

Download iOS certificates from Xcode on an iMac - MAUI raises on iOS MT1045
Downlaod iOS certificates from Xcode

Turn on Developer Mode

  1. On your device, go to Settings > Privacy and Security.
  2. Inside Privacy and Security screen, scroll to the bottom to find Security section and Developer Mode.
  3. Tap on Developer Mode.
  4. Inside Developer Mode screen, turn on Developer Mode.
  5. When prompted with “When Developer Mode is turned on, your device security will be reduced. Restart your device to turn on Developer Mode, tap on “Restart”.
  6. Once restarted, you’ll get another prompt, “Turn on Developer Mode? Developer Mode allows you to use features that are required for app development. When Developer Mode is turned on, your device security will be reduced.”, tap “Turn On” to turn on Developer Mode on your device.
Turn on Developer Mode on iOS - MAUI raises on iOS MT1045
Enable Developer Mode on iOS
Turn on developer mode on iOS- MAUI raises on iOS MT1045
Enabled Developer Mode on iOS

Still not working?

My iPhone on Xcode

Next, I want to verify if my device is paired with Xcode. The Xcode version I use is 15.4.

Xcode version - MAUI raises on iOS MT1045
Xcode version

In order to pair or see the list of paired devices, open the menu Window and then Devices and Simulators. In this window, you have the status of all devices. If the pair is in progress, you see a yellow band on the top of the window.

Pair devices on Xcode

How to find the issue?

The app is still not working. Next step is to investigate more about the reason. From the window Devices and Simulators, for each device you can open the Console and filter for the name of your app, for example.

Devices and Simulators on Xcode

Now, the Console for your device, show you all the logs on the device for everything. You can stop the flush of data and filter them. For example, this is the screen I get. If you click on a row, you see all the details in the window below.

Using this tool, I can see the following error:

-[IXSDataPromise cancelForReason:client:error:]: <IXSPromisedStreamingZipTransfer(0x4f8224070) Name:Language In Use Creator:InstallCoordination Proxy UUID:7E0B11CD-2C5A-4A93-BB8F-25A8469DE53B PercentComplete:1.000000 IsComplete:Y DiskUsageBytes:54416934> : canceled by client 17 for reason Error Domain=IXUserPresentableErrorDomain Code=14 "This app was not installed because its integrity could not be verified." UserInfo={NSUnderlyingError=0x4f82b0030 {Error Domain=MIInstallerErrorDomain Code=13 "Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.jm7AyD/extracted/LanguageInUse.app : 0xe8008015 (A valid provisioning profile for this executable was not found.)" UserInfo={NSLocalizedDescription=Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.jm7AyD/extracted/LanguageInUse.app : 0xe8008015 (A valid provisioning profile for this executable was not found.), LegacyErrorString=ApplicationVerificationFailed, SourceFileL

This error is generated for different reasons. First, check if the device is registered on the Apple Developer website.

Register the device on Apple Developer website

My solution was to go to developer.apple.com > Devices and add my devices using Device ID (UDID). This was obtained by plugging device into a mac, selecting in finder, and clicking the top device banner to copy the UDID. Then, I had to create a new ad hoc profile and add the devices to the profile. Finally, I had to download and select the new profile in Targets > Signing and Capabilities.

Push notifications

If your app is using the push notifications, remember that in the Entitlements.plist there is a key. If you try to deploy on your device the app but the channel is Production, the MAUI deployment raises on iOS the error MT1045.

So, remember to change those lines in the Entitlements.plist. When you test the application, those lines are

<key>aps-environment</key>
<string>development</string>

when you deploy the application on the Apple Store, you have to change them:

<key>aps-environment</key>
<string>production</string>

Delete certificates and profiles

For the outdated Profiles, you can skip it via manual provisioning or you can delete it, in Windows is under (C:\\Users\{username}\\AppData\\Local\\Xamarin\\iOS\\Provisioning or Certificates), Mac is under ~/Library/MobileDevice/Provisioning Profiles/. You can delete it and then restart the VS and then pair it to Mac again. 

Trouble with NET8

Visual Studio 2022, Visual Studio for Mac and Visual Studio Code make me crazy when I have to deploy apps for iOS (and macOS). I have my .NET8 MAUI application that is working on Windows and Android. I can deploy the application to an iPhone Simulator and a real device.

After the upgrade of Visual Studio on my Windows to the version 17.10.1, I can’t build a release of the app to deploy it on a real device or create the package for the Apple Store.

So, I tried to build the application on Visual Studio for Mac or Visual Studio Code. In both cases I get this error

.NET 8.0 SDK is required to build this application, and is not installed. Install the latest update to the .NET 8.0 SDK by visiting https://aka.ms/vs/mac/install-netcore8

I installed I don’t know how many times the NET8 package but there is no way to get this message out. So, I open again Visual Studio for Mac and I found that I have to enable the option for NET8 under Preview Features.

Visual Studio for Mac - Preview features

If I try to run the project, I get this error

error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0.

There are months I’m fighting with the creation of iOS apps. It is not very stable. One day is working, another is not. The only think I’m doing is changing the configuration between development and production.

Wrap up

In conclusion, this is what I checked when MAUI raises on iOS MT1045 during the development and testing process on my local devices. If you have more checks or advice, please text me or add a comment and I will add your suggestions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.