Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings.bundle/Root.plist doesn't get included in iOS bundle. Maui.Storage.Preferences has no methods to save "shared" settings into device settings. #9122

Closed
belmonmi opened this issue Aug 1, 2022 · 12 comments · Fixed by #23269
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer fixed-in-8.0.70 fixed-in-9.0.0-preview.7.24407.4 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@belmonmi
Copy link

belmonmi commented Aug 1, 2022

Description

Settings.bundle/Root.plist in iOS and Xamarin Forms is used to have "shared" setting for an application that user can modify by going to iPhone/iPad device settings. .Net MAUI is ignoring that file under Platforms/iOS/ folder.

Steps to Reproduce

  1. Create new .Net MAUI application.
  2. Under Platforms/iOS folder create "Settings.bundle" folder
  3. Create new file "Root.plist" with some simple PSTitleValueSpecifier or PSGroupSpecifier, or any other valid iOS specifier with Title, Type, Key and Value.
  4. Build the solution.
  5. Run it on iOS simulator.
  6. Go to device settings - no settings from your "Root.plist" only "Debug" settings that MAUI put there.

Version with bug

6.0.408 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iPhone 12 Pro iOS 15.5

Did you find any workaround?

No

Relevant log output

No response

@belmonmi belmonmi added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Aug 1, 2022
@belmonmi
Copy link
Author

belmonmi commented Aug 2, 2022

noSettings

@jfversluis jfversluis changed the title Settings.bundle/Root.plist doesn't get included in iOS bundle. Maui.Storage.Prefernces has no methods to save "shared" settings into device settings. Settings.bundle/Root.plist doesn't get included in iOS bundle. Maui.Storage.Preferences has no methods to save "shared" settings into device settings. Aug 2, 2022
@jfversluis jfversluis added area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer platform/iOS 🍎 and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Aug 2, 2022
@jfversluis jfversluis added this to the .NET 7 Planning milestone Aug 2, 2022
@jfversluis
Copy link
Member

Not 100% sure but this one looks very much like #8612

@belmonmi
Copy link
Author

belmonmi commented Aug 2, 2022

This is what I thought, but it is completely different. :) I already tried all possible variation of that but no luck. I still cannot populate shared iOS device settings. Using Preferences works to save and read the settings, but we need something similar to Xamarin Forms Settings.bundle/Root.plist functionality.
Thank you,
Michael.

@bivant
Copy link

bivant commented Sep 16, 2022

Same issue
If try to apply workaround from #8612

	<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
		<MauiAsset Include="Platforms\iOS\Settings.bundle\Root.plist" LogicalName="Settings.bundle\Root.plist" />
	</ItemGroup>

The Root.plist has pre-defined by MAUI content only (in bin/Debug/net6.0-ios/iossimulator-x64/APP/Settings.bundle). If change the LogicalName path to Root2.plist - the file is present in the app-settings bundle but not used by iOS system as it checks Root.plist only.

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/UserDefaults/Preferences/Preferences.html

The Settings Bundle
A Settings bundle has the name Settings.bundle and resides in the top-level directory of your app’s bundle.
...
When the user taps the row belonging to your app, Settings loads the Root.plist Settings page file for your Settings bundle and uses that file to build your app’s main page of preferences.

@rxDietel
Copy link

rxDietel commented Sep 16, 2022

This works for me as a workaround:

  <ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
    <BundleResource Include="Platforms\iOS\Settings.bundle\Root.plist" Link="Settings.bundle\Root.plist" />
  </ItemGroup>

@bivant
Copy link

bivant commented Sep 16, 2022

Hello @belmonmi
I confirm that @rxDietel workaround works. I think you can update the topic that workaround exists.
Looks like this Settings

@belmonmi
Copy link
Author

Hi @bivant ,

Finally I was able to connect my VS to Mac and try the solution. It is working. I can see the app setting in iPhone system settings now.
Thank you very much.

@rebuscao
Copy link

Hello, I tryed this workaround. It works and I can see the options in the config of the app but I lost the last part related to debug setting. This causes the app not connecting to debugger using local device on VS2022.

Maybe I need to add the default debug setting on my custom Root.plist but I don't know the exact setup.

Hello @belmonmi I confirm that @rxDietel workaround works. I think you can update the topic that workaround exists. Looks like this Settings

@bivant
Copy link

bivant commented Aug 24, 2023

Hello @rebuscao
The debug section is added automatically for me. No such values in Root.plist of the Settings.bundle
Have you tried the App delete/install, device restart? Maybe you build a release configuration?

@belmonmi
Copy link
Author

@rxDietel workaround works. Thank you.

@samhouts samhouts modified the milestones: .NET 8 Planning, Under Consideration Sep 27, 2023
@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Dec 14, 2023
@Zhanglirong-Winnie
Copy link

Verified this issue with Visual Studio Enterprise 17.9.0 Preview 2. Can repro this issue.

@samhouts samhouts modified the milestones: Under Consideration, .NET 8 SR7 Jul 1, 2024
@steven-pearson
Copy link

@rxDietel workaround works great, searched everywhere to find out why the settings would not deploy, was missing the Link= parameter.

MS should really add this to their docs.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer fixed-in-8.0.70 fixed-in-9.0.0-preview.7.24407.4 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants