Will Swift Documentation include File I/O?

Hi everyone, I was working on my school programming language research course with Swift, for basic syntax and language philosophy it is great but lacking of some an official support on basic things like File I/O and I need to search on SO or Google it to get an answer.

For some basic programming features like File I/O, console read line, or linking, will they be considered included in the documentation?

Thank you

1 Like

The official documentation [1] includes links to the standard and core libraries. For File I/O try Foundation FileManager.

[1] https://www.swift.org/documentation/

3 Likes

Thank you, then I wish the next iteration will include them in the Swift Tour,

I believe it is quite important for the non-Xcode developers to use Swift outside of the Apple ecosystem

2 Likes

Hello, @DavidKo

Unfortunately, most of the official documentation is inadequate, and TSPL is dead.

Your best bet is to get help on these forums, by asking intelligent questions. :slight_smile:

You can also learn quite a bit, if you persist, by reading the Swift evolution proposals.

Is it?

3 Likes

oh yea I totally forgot this, thank you!

Not exactly speaking to your question on documentation but I get the feeling that File I/O is very much an area of active development, as well.

Here is a thread with a lot of pointers:

Thanks for sharing, I am very new to Swift development. especially non-iOS, the reason I raised the question was because after some googling for the answer, it was either Bundle.main.url() or Bundle.module.url() to access the Sources/Resources directory, and later find out about the FileManager API, and now I see the FileHandler let me have a look

Honestly I do much more Linux/MacOS than iOS so I try to write packages that will work both in an apps bundle or the CWD.

  • Are you trying to mostly access included files or work with external files?
  • What OS's are you targeting?

FWIW, the folks working on FileManager and SwiftNIO are huge heroes in my book for even thinking about an API that will work with a non POSIX system! I'm way too lazy so using those libraries are a very good solution.

Also - if you want to see some pretty pro file handling using So. Many. Frameworks....

2 Likes

Hi there, currently I am only doing it for a school assignment therefore it is include files or just within the project root.

For OS i assume crossed platforms because the professor might run on his windows machine, of course I don't see there is a chance of that but let's assume all 3 major OS

thanks for sharing the resources I'll have a look at it

1 Like

I would recommend the exact opposite of this. Unless your other options are even worse, like JS.

Both considering the current state of the cross-platform standard libraries and the current state of developer support of Apple.

It is. It is the only way for the language to grow and flourish. There are a lot of good choices present in Swift’s design. It’d be a shame to delegate it as just an Apple programming language.

The feedback from beginners is super valuable and welcome. There are a lot of areas lacking[1]. Yet still I wouldn’t want to discourage anyone from trying out Swift.

As for cross-platform support… There are a lot of people working on it, and it is getting better steadily. Although myself, I feel pretty comfortable recommending Swift for making Linux or even Windows binaries.

If there are any frustrations you encounter feel free to reach out. It would help bring these issues to our attention.

Also, why is JS catching strays here? That seems reductive


  1. Just like the documentation on file I/O. Which is a pretty fundamental thing ↩︎

2 Likes

And also I remember Apple wants Swift to be a system programming language not just building mobile apps.

As tsoding pointed out the interoperability with C is surprisingly good but no public or clear documentation on that.

So far I am enjoying Swift a lot, even learnt to use TabularData and telling people who are on Windows to try it out, if we want to see Swift one day will be as widely used as Java, some of obvious topics like file system should be mentioned.

Again thanks for the team behind it, great language just lots of keywords :sweat_smile:

1 Like

I do remember that. I wish I wasn’t so lazy, and elevated criticisms brought forward to the larger Swift community right when the stream aired. Oh well.

#include <stdlib.h>

I often find myself “writing C in Swift” just because I don’t know nor want to look up the blessed swift-specific way of doing things. It works surprisingly well[1]


  1. -ish. Pointers types have super long UnsafeMutablePointer<Type> names, allocating memory on stack is troublesome (can we have InlineArray pls?), doing pointer arithmetic is really verbose ↩︎

1 Like

Is the Swift System package what you’re looking for?

https://swiftpackageindex.com/apple/swift-system/1.4.2/documentation/systempackage/filedescriptor

2 Likes