apple / FHIRModels

Swift library for FHIR® resource data models
Apache License 2.0
178 stars 31 forks source link

Linux compatibility? #4

Closed mariusom closed 4 years ago

mariusom commented 4 years ago

I know there is some effort to make a Swift project cross platform currently, but I was wondering if there was any plan to support the library on Linux?


I've managed to build and test the project in Linux for version 0.2.0, by overcoming 3 cross platforms issues:

  1. The call to scanCharacters function in Scanner+FHIR.swift for older version of apple platforms (pre macOS 10.15 / iOS 13 / watchOS 6 / tvOS 13).

  2. String formatting using the %@ formatSpecifier, is not supported under Linux yet, but hopefully will be a non issue thanks to swift corelibs foundation PR 2821 and swift PR 32311.

  3. This last point is related to testing but having JSONEncoder use withoutEscapingSlashes for outputFormatting. Seems to be a solved issue in the upcoming Swift 5.3.

p2-apple commented 4 years ago

Great, thanks for reporting! I'd definitely like to make this compile on Linux and I'm happy to change 1) and 2). Regarding withoutEscapingSlashes, are you saying that Linux doesn't have that option yet but will have it in 5.3?

mariusom commented 4 years ago

Hope this clarifies the issue. Swift in Linux versions:

millenomi commented 4 years ago

We accept candidates for the 5.2.x monthlies, and withoutEscaping… looks like an acceptable backport to me. Just send a PR to apple/swift-corelibs-foundation and @ me to get that rolling.

p2-apple commented 4 years ago

Hey @mariusom , can you check how feature/linux-compatibility is working for you?

mariusom commented 4 years ago

Hey @p2-apple, so it's just missing the "LinuxMain.swift" file in the "Tests" folder.

After adding that file, it builds successfully with version 5.2.5 and latest 5.3-dev nightly.

I also, came across a test which keeps alternating between pass/fail in "Tests/ModelTests/DecodeEncodeTests.swift" for the "testDecodeEncodePrimitiveWithOnlyExtension" test. I think the encoder is missing the sortedKeys for outputFormatting and the "url" and "valueString" keep swapping places.


I will have to look a bit more into apple/swift-corelibs-foundation since the "withoutEscapingSlashes", was working with an older version of 5.3-dev. So will have to see how an older version of 5-3 was working, but will move that issue as @millenomi suggested over to that repo hopefully with a PR to backport it.

p2-apple commented 4 years ago

Ah great, thanks for the pointer! I've also improved testDecodeEncodePrimitiveWithOnlyExtension(). Pushed, LMK if this looks good now!

mariusom commented 4 years ago

Checked it all again and everything looks good to me.

Thank you for making these changes and being so responsive.