Skip to content

Add extension to String init(contentsOfFile:encoding)#100

Open
guillaumealgis wants to merge 1 commit intomxcl:masterfrom
guillaumealgis:string-init-contentsoffile-encoding
Open

Add extension to String init(contentsOfFile:encoding)#100
guillaumealgis wants to merge 1 commit intomxcl:masterfrom
guillaumealgis:string-init-contentsoffile-encoding

Conversation

@guillaumealgis
Copy link

@guillaumealgis guillaumealgis commented Mar 6, 2026

The init(contentsOfFile:) initializer of String is deprecated since macOS 15 / iOS 18.

This PR adds a new extension init(contentsOf:encoding:) to String accepting a Path for contentsOf, and calling to Foundation initializer init(contentsOfFile:encoding:).

I also took the liberty to apply the same deprecation notice on init(contentsOfFile:) as the ones in Foundation. This can go if you think this is not warranted.

  • Added tests covering this new API

@guillaumealgis guillaumealgis force-pushed the string-init-contentsoffile-encoding branch from 18bbb1f to 5c11554 Compare March 6, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant