memoryio / memoryio-macosx-swift

Life logging app for macosx. Takes a picture with built in isight whenever you wake computer from sleep
https://www.memory.io
2 stars 1 forks source link

NSUserDefaults not being brought over from 1.x #3

Closed jacobrosenthal closed 6 years ago

jacobrosenthal commented 6 years ago

Looks like I found a swift bug.. sigh My 1.x NSUserDefaults keys have a dash in them, and theyre not showing up on the swift api side, but they do show up in a bridged objc file.

$ xcodebuild -version
Xcode 9.3.1
Build version 9E501
$ swift --version
Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)
Target: x86_64-apple-darwin17.5.0

Inside a bridged Objective C

    NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
...
    "com.apple.trackpad.twoFingerFromRightEdgeSwipeGesture" = 3;
    "com.apple.trackpad.version" = 5;
    "key-with-dashes" = 1;
...

inside my main.swift all the keys (and only the keys) with dashes are missing

    for (key, value) in UserDefaults.standard.dictionaryRepresentation() {
        print("\(key) = \(value) \n")
    }
...
    "com.apple.trackpad.twoFingerFromRightEdgeSwipeGesture" = 3;
    "com.apple.trackpad.version" = 5;
...
jacobrosenthal commented 6 years ago

Filed a radar http://openradar.appspot.com/radar?id=4987498409230336

We all know how this goes. That might never get fixed.

Going to have to build the first time nsuserdefaults import in objc and rekey without the hyphens.

Maybe use a dep like https://github.com/sindresorhus/Defaults