Heads up: Paths changing for CFPreferences and UserDefaults

I'm doing quite a bit of work to make Foundation a better citizen on non-Darwin platforms, and part of it is follow relevant filesystem location specs that Linux and other Unix-y OSes support.

As part of this, I'm pushing https://github.com/apple/swift-corelibs-foundation/pull/1399 and I think it merits a heads-up: on platforms other than Darwin, we are going to use the following paths:

  • /usr/local/etc for …AnyUser preferences;
  • $XDG_CONFIG_DIR for …CurrentUser preferences. This usually resolves to (and defaults to) $HOME/.config/.

If you have apps that store preferences, you may want to note the change and perhaps plan a move of existing defaults files, if you're using UserDefaults in your app. You can also provide feedback here or, for code-level issues, on the pull request.


Hey @millenomi!

Great to read some activities here on this topic :+1:t2:.
I'm developing a Swift application for the ARM architecture (RPi 3 with Raspbian). Currently it only supports the Swift 3.1 toolchain, unfortunately. So I wonder if I will be able to use UserDefaults on this architecture with the outdated Swift version too? Actually I can "use" it, but setting values to the store always returns nil.

Maybe you can bring some light into the darkness... what's the current (and planned) state of it?

Thanks in advance!

1 Like

Hi @phranck,

We're planning on doing this work in the master branch of swift-corelibs-foundation, as part of the work for Swift 5.

Back-porting it all to the Swift 3.1 branch may be possible - I don't think we are using anything new and fancy in the Swift for UserDefaults -- although the rest of swift-corelibs-foundation does.

We have to leave this as an exercise to the reader though. :)

1 Like