-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
p: shared_preferencesPlugin to read and write Shared PreferencesPlugin to read and write Shared Preferencespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyplatform-macBuilding on or for macOS specificallyBuilding on or for macOS specificallyteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem team
Description
What package does this bug report belong to?
shared_preferences
What target platforms are you seeing this bug on?
iOS
Have you already upgraded your packages?
Yes
Dependency versions
No response
Steps to reproduce
- Write a key to the standard user defaults
- Write a key to user defaults using suite name
- Read all the keys using suite name
- Only the key that belongs to the standard user default is returned
Expected results
Reading all the keys using a suite name should return all the keys for that suite (i.e. domain).
Actual results
The package is only returning keys from the standard user defaults.
Code sample
Test that shows failure
let optionsWithSuiteName = SharedPreferencesPigeonOptions(suiteName: "group.example.sharedPreferencesFoundationExample")
func testAsyncGetAllWithAndWithoutSuiteName() throws {
let plugin = SharedPreferencesPlugin()
try plugin.set(key: "aKey", value: "hello world", options: emptyOptions)
try plugin.set(key: "aKeySuite", value: "hello world with suite", options: optionsWithSuiteName)
let storedValues = try plugin.getAll(allowList: nil, options: emptyOptions)
XCTAssertEqual(storedValues["aKey"] as? String, "hello world")
let storedValuesWithGroup = try plugin.getAll(allowList: nil, options: optionsWithSuiteName)
XCTAssertEqual(storedValuesWithGroup["aKeySuite"] as? String, "hello world with suite")
}In the test above, the last assert fails. To run the test, add it to shared_preferences_foundation/darwin/Tests/RunnerTests.swift and run it from Xcode using the example project located in shared_preferences_foundation/example/ios.
I'll submit a PR with the fix and the test.
Screenshots or Videos
No response
Logs
No response
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-x64, locale en-US)
• Flutter version 3.22.2 on channel stable at ...
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 761747bfc5 (9 weeks ago), 2024-06-05 22:15:13 +0200
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at ...
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
[✓] VS Code (version 1.91.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.94.0
[✓] Connected device (5 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 14 (API 34) (emulator)
• iPhone 15 Pro (mobile) • 8F6601E7-2C55-4FEA-96BB-679E4301ECFD • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 14.5 23F79 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.90
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.
Metadata
Metadata
Assignees
Labels
p: shared_preferencesPlugin to read and write Shared PreferencesPlugin to read and write Shared Preferencespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyplatform-macBuilding on or for macOS specificallyBuilding on or for macOS specificallyteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem team