There are times on this blog when I write posts for the reader’s benefit and times when I need to memorialize my own pain and suffering to find a solution to a seemingly simple issue. This post is the latter.
In this post, we’ll see what it takes to fix the MissingEntitlement
and “Could not find any available provisioning
profiles” errors.
Also, be warned: You might not like what you see.
Ok, let’s go!
iOS, Security, and Entitlements
I recently purchased the “.NET MAUI in Action” book and was working through the sample application in Chapter 3. The author’s perspective differs from mine in that their app targets Windows, and I am targeting iOS. As one might expect, the details between the two target platforms differ.
This difference led to my first issue running the sample application targeting iOS; I got this exception and crashed the application.
System.Exception: Error adding record: MissingEntitlement
at Microsoft.Maui.Storage.KeyChain.SetValueForKey(String value, String key, String service)
at Microsoft.Maui.Storage.SecureStorageImplementation.SetAsync(String key, String value, SecAccessible accessible)
at Microsoft.Maui.Storage.SecureStorageImplementation.PlatformSetAsync(String key, String data)
at Microsoft.Maui.Storage.SecureStorageImplementation.SetAsync(String key, String value)
at Microsoft.Maui.Storage.SecureStorage.SetAsync(String key, String value)
This leads users to the first issue, a missing Entitlements.plist
file. What are Entitlements?
Side Note: The MissingEntitlment
exception could really use a more helpful error message. WHICH ONE MAUI? WHICH
ONE?!
All iOS applications are sandboxed, allowing the app only to execute iOS functions it has requested and explicitly been
granted by the user. Entitlements ensure apps behave as intended and don’t expose users to unnecessary risks. For your
application to use iOS features like Maps, KeyChain, or Siri, you must first add values to the Entitlements.plist
file
to request access. Only then can you use these features.
You can read more about Entitlements on the Microsoft documentation site.
Side Note: I would think the .NET MAUI template would have an empty entitlements file already in the Platforms/iOS
folder, but
it
doesn’t.
So, in the Platforms/iOS
folder, you’ll need to create an Entitlements.plist
file with the following XML.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
For enabling the Maps feature, your Entitlements.plist
file might look like the following.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.maps</key>
<true/>
</dict>
</plist>
You can also use JetBrains Rider’s plist editor to create and manage these files with schema validation and an excellent UI experience.
You should be good to go, right? Not so fast. Running your application now presents you with the following error.
1>Xamarin.Shared.targets(1820,3): Error : Could not find any available provisioning profiles for MauiTodo on iOS.
Wait…. what?! What’s going on? I’m only trying to deploy to the iOS simulator!
Provisioning Profiles, Apple Developer Account, and Physical Devices
Adding the Entitlements.plist
file has cascaded into a secondary issue in the build process. (Note that I’m currently
using .NET 8.0 and 9.0 workloads).
1>Xamarin.Shared.targets(1820,3): Error : Could not find any available provisioning profiles for MauiTodo on iOS.
MAUI is looking for a provisioning profile. What is a provisioning profile?
A development provisioning profile allows your app to launch on devices and use certain app services during development. For an individual, a development provisioning profile allows apps signed by you to run on your registered devices. For an organization, a development provisioning profile allows apps developed by a team to be signed by any member of the team and installed on their devices. –Apple
Huh. How do you fix this issue? I just want to deploy my app to my local simulator.
Here are the steps you’ll need to fix this, and I’ll start with the two most significant hurdles.
- A physical iOS device. Yes, you will need a physical device.
- An Apple Developer Account at $99/year. Sign up here or give up now.
- macOS and XCode
First, Be sure to enable Developer Mode on your device. You’ll need the identifier for this physical device. To get your device’s UUID, connect your iOS device to your macOS machine and launch XCode. Open “Window | Devices and Simulators.” Here, you’ll see your device’s ID. You’ll need this to register the device.
Log in to your new Apple Developer account and add your physical device. You can visit the “Register a New Device” page. Here, you’ll register the physical device, at which point you’ll get a provisioning profile.
Now, open your MAUI project in XCode (which you can do from JetBrains Rider). Under the Project settings’ “Signing & Capabilities” tab, select a Team and check the Automatically manage signing checkbox. If you don’t see a Team, be sure to add your Apple Developer account to Xcode under “Settings | Accounts” and try again.
If all goes well, you should see values for the Provisioning Profiles and Signing Certificate fields in the bottom iOS section.
Now, you can go back to building and deploying your application with Entitlements to the iOS simulator without any issues. Xcode will handle signing your apps from here on out.
Conclusion
The steps outlined here fixed my issue, but honestly, it took way longer and a significant amount of money 💰 to solve this issue, given the price of a physical iOS device and an Apple Developer subscription. I am still not sure if this is an Xcode and iOS issue or a MAUI issue. All I know is that it’s a MAUI developer stumbling block that I ran into, and it’s now “solved.”
I hope this post helps you on your MAUI development journey. Cheers.