Skip to content

FileStorageKey (Default) Creates Empty File Instead of Populating It with Data #166

Description

@zachgibson

Description

When using FileStorageKey<String>.Default, I’m seeing an issue where the file is created on disk with no contents, even though a default value is provided and used in memory. If I update that state the file then gets populated correctly.

Image

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

FileStorageKey<T>.Default with a non-nil default value creates a file on disk with the contents of default value.

Actual behavior

FileStorageKey<T>.Default with a non-nil default value creates an empty file on disk.

Reproducing project

FileStorageRepro.zip

Sharing version information

2.5.2

Destination operating system

macOS 15.3.1

Xcode version information

16.2

Swift Compiler version information

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions