Replies: 12 comments
-
Can you share a small sample where reproduce the issue or paste your Entitlements Configuration? |
Beta Was this translation helpful? Give feedback.
-
Hi @jsuarezruiz. Please find the below code I am unable to upload the sample it shows its failing. please find the below code and configuration. 1.Entitlements.plist inside code ` keychain-access-groups com.companyname.securestoragemaui ` 2. I mentioned in project file like below as per Microsoft documentation. ` Platforms\MacCatalyst\Entitlements.plist ` 3. its code behind code its `private async void Save(object sender, EventArgs e) { string savedToken = SaveToken.Text; if (!string.IsNullOrEmpty(savedToken)) { await SecureStorage.Default.SetAsync("oauth_token", savedToken); SaveToken.Text = string.Empty; await DisplayAlert("SAVED", "Token saved", "Ok"); } else { await DisplayAlert("ERROR", "Please enter the token", "Ok"); } }` |
Beta Was this translation helpful? Give feedback.
-
A couple of things:
Double-check if your |
Beta Was this translation helpful? Give feedback.
-
@jfversluis I have created the .Net 9.0 and fallowed the Microsoft document for configure the Entitlements.plist and run the App but still I am getting the same Error but same setup working in IOS only problem with Mac catalyst If you need any Info please let me know. |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
Hi @jfversluis, Could you please help me understand what might be wrong with this? Please see the screenshot below. I followed the reference provided. I have tried like this way also but still getting the same error.
|
Beta Was this translation helpful? Give feedback.
-
I spent yesterday evening trying to get this to work with no joy. I'll have another go over the weekend and document what I find. I didn't want anybody thinking this was an isolated report. |
Beta Was this translation helpful? Give feedback.
-
I did get it working. Here are the notes: BackgroundI haven't been able to get this to work for some time and it's been bugging me. So, while the below is not likely to be the most elegant approach, it did work. I tried this on a test application created from scratch and then on my main application where I want this to work. Headline
Gotchas (be aware)
ActionsApp Developer Portal
Copying the file
security cms -D -i YourApp.provisionprofile or security cms -D -i <PathToYourApp>/YourApp.provisionprofile You should see lots of information you recognise. Your CodeI have JetBrains Rider as my development environment on the Mac. I will try to show code where I can to avoid variations of development software environment. YourApp.csprojThere are several changes to make in the .csproj file. Note that I'm concentrating on the development process. There will be something similar for your release cycle but I don't know what that is yet. Notes
1. Target the new profileIt's import to separate the iOS provisioning from that of Mac Catalyst. I'm sure you will adapt accordingly over time, but I start with this on a test application: <PropertyGroup Condition="'$(TargetFramework)'=='net9.0-ios'">
<CodesignKey>Apple Development: Created via API (2********Z)</CodesignKey>
<CodesignProvision>PortableStorageApp Development</CodesignProvision>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net9.0-maccatalyst'">
<CodesignKey>Apple Development: Created via API (2********Z)</CodesignKey>
<CodesignProvision>PortableStorageApp Development (Mac)</CodesignProvision>
</PropertyGroup>
Try running the application now on your Mac. I have no hard and fast suggestions but I tend to Clean and then Build the solution before doing anything else. If that isn't working (you have errors), I've also had to remove the project's bin and obj directories. However if I've deleted bin and obj, I've also had to do the below command from inside the project directory (not solution) following the removal of those directories. I wish I could spot the pattern of when it works, but I have nothing so far. I should also point out that AI will suggest removing bin and obj at the drop of a hat. I didn't have to remove them for the whole process when applying this to my main application. dotnet restore Next, you need to reference to two Entitlements.plist files (one for iOS and one for Mac Catalyst). THEY MUST EXIST TO GO ANY FURTHER. In your .csproj, add this: <PropertyGroup Condition="'$(TargetFramework)' == 'net9.0-ios'">
<Entitlements>Platforms/iOS/Entitlements.plist</Entitlements>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0-maccatalyst'">
<Entitlements>Platforms/MacCatalyst/Entitlements.plist</Entitlements>
</PropertyGroup> They can probably go in without change. Entitlements.plistThis proved very difficult, made harder by an AI suggesting several things at once to make things work. Here are public facing versions of the file for my projects. iOS<?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">
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.-->
<dict>
<key>keychain-access-groups</key>
<array>
<string>3********C.uk.co.yourdomain.YourApp</string>
</array>
</dict>
</plist> Mac Catalyst<?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">
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.-->
<dict>
<!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. -->
<key>com.apple.security.app-sandbox</key>
<true/>
<!-- When App Sandbox is enabled, this value is required to open outgoing network connections. -->
<key>com.apple.security.network.client</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>3********C.uk.co.yourdomain.YourApp</string>
</array>
</dict>
</plist> In terminal, navigate to the directory for the compiled application. In my case, that's here in relative terms from the Application. It will be different in you're on an Intel chip device.
Once in that directory, you can execute this command: codesign -d --entitlements - YourApp.app This will show the entitlements associated with YourApp. The output will be similar to this (some comments and anonymisation in this sample - I've hidden most of my Team ID, for example):
It's time to try your application again. SecureStorage codeI got very lazy with this so put my immediate test code into App.xaml.cs. Quick testI wanted something very quick before I tried loading my service that used SecureStorage I'd written some months ago. Here is a one liner as a start. At the end of the constructor of App.xaml.cs, add this line: SecureStorage.Default.Remove("not_there"); It doesn't matter that the key does no exist. You just want it to run the line to prove it can access SecureStorage without error. Remove the line when you're ready to do the below. Longer testTry adding this at the end of the constructor and stepping through the code to make sure it writes, reads and removes an entry. Don't forget to remove it when you have it working. Task.Run(async () =>
{
await SecureStorage.Default.SetAsync("testKey", "testValue");
var value = await SecureStorage.Default.GetAsync("testKey");
SecureStorage.Default.Remove("testKey");
}).Wait(); ConclusionI wish it was easier and I expect it to be less fraught when it comes to do it for production/distribution. Also, my apologies for typos and any omissions. |
Beta Was this translation helpful? Give feedback.
-
Does that help at all @Sgudipu ? |
Beta Was this translation helpful? Give feedback.
-
Hi @jfversluis, |
Beta Was this translation helpful? Give feedback.
-
Hi @sumowesley, Could you please confirm if this issue is caused by either an incorrect or missing keychain-access-groups entry in the entitlements.plist, or a mismatch between the app’s bundle identifier/keychain access group and the provisioning profile? I have re created the provisioning profile and verified as you mentiond but still I am getting the same lunch fail issue. |
Beta Was this translation helpful? Give feedback.
-
@Sgudipu , I think it's better to think of it as many things needing to align before it will work. If you've worked through my list, at what stage does the application fail? There several places where you can launch the application. How early does it fail? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
When attempting to use Secure Storage in a .NET MAUI app targeting Mac Catalyst, the application fails to launch with the following error:
The application cannot be opened for an unexpected reason, error=Error Domain=RBSRequestErrorDomain Code=5 "Launch failed."
UserInfo={NSLocalizedFailureReason=Launch failed.,
NSUnderlyingError=0x122205be0 {Error Domain=NSPOSIXErrorDomain Code=153 "Unknown error: 153"
UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}
Steps to Reproduce
Link to public reproduction project repository
No response
Version with bug
10.0.0-preview.4
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
No response
Affected platforms
macOS
Affected platform versions
MAUI Mac catalyst
Did you find any workaround?
No response
Relevant log output
Beta Was this translation helpful? Give feedback.
All reactions