dotnet / dotnet/runtime

ApplicationSettingsBase.Upgrade does not locate previous settings on iOS

Open
#121,053 7 comments 0 reactions 1 assignee Claimed by @steveisok View on GitHub
area-System.Configuration os-ios
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Description

When updating an iOS application that uses old style application settings, upgrading settings from a previous version fails since the previous settings are not found.

### Reproduction Steps

1. Clone repro repo: https://github.com/jeremy-visionaid/MauiTestApp/tree/settings-upgrade
2. Run on an iOS device
3. Click button to upgrade settings

### Expected behavior

Settings should upgrade succesfully when the version is incremented

### Actual behavior

Settings upgrade is required every install and the previous settings are not found

### Regression?

_No response_

### Known Workarounds

Implement a new `SettingsProvider`

### Configuration

dotnet SDK 9.0.306
Xcode 26.0.1
Running on iOS 26.0.1 ARM64

### Other information

It appears that the app-specific settings folder varies between installs of the same version on iOS. E.g. if on TestFlight you install versions in the following order (1.0.0-1, 1.0.0-2, 1.0.0-1, 1.0.0-2), then the Documents directory ends up with 4 directories for the settings, when there should only be 1 (with a subdirectory for each version).

https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/application-settings-overview#where-are-user-scoped-settings-stored

So, it seems likely that there's some issue with the way the hash is being calculated on iOS (it works as expected on Catalyst for a non-sandboxed app at least)

I've also set:
```
UIFileSharingEnabled

UISupportsDocumentBrowser

```
which exposes the files as per #120892

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.