Anviking / Decodable

[Probably deprecated] Swift 2/3 JSON unmarshalling done (more) right
MIT License
1.04k stars 73 forks source link

added Linux compatibility #132

Open codeOfRobin opened 7 years ago

codeOfRobin commented 7 years ago

Though it still will generate warnings on MacOS. Another thing that's weird is, swift build won't work because of the files in the Tests folder.

Someone who's more well versed with Swift Package manager should probably check up on this(I am open to discussing possible restructuring in the comments).

The changes are, otherwise, super small (adding ?s. Though Atom seems to have messed up the whitespace somehow ¯\_(ツ)_/¯

voidref commented 7 years ago

There are a lot of whitespace changes in this. Was this on purpose or is it your editor deciding this?

I think it's best if the PR is just the logic changes. We can always go and do whitespace fixes in a dedicated change.

codeOfRobin commented 7 years ago

I suspect it's Atom doing it. ¯_(ツ)_/¯.

voidref commented 7 years ago

Ah, sorry missed that it was Atom.

I'm not comfortable accepting this PR with all the whitespace changes, but it might be ok with @Anviking

codeOfRobin commented 7 years ago

I'll split it into 2 PRs (I think that's an amicable solution).

codeOfRobin commented 7 years ago

BTW @Anviking There's another reason a linux port would be hard. NSDictionary <-> Swift dictionary conversion on Linux is buggy as hell. For example,

let y: [String: Int] = ["a": 1]
guard let x = y as? NSDictionary else {
    print("not succeeded")
    exit(1)
}

will work on MacOS but will fail on Linux ( warning: cast from '[String : Int]' to unrelated type 'NSDictionary' always fails )

Turns out, this won't be possible on Linux at all (I posted this bug earlier today): https://bugs.swift.org/browse/SR-3411

Does this mean, there's no way to get Decodable onto Linux?

Anviking commented 7 years ago

@codeOfRobin I think the dependency on NSJSONSerialization could be separated (with #if os) quite easily. Would be kind of interesting to do actually. Would need a suitable replacement parser though.