tsolomko / SWCompression

A Swift framework for working with compression, archives and containers.
MIT License
233 stars 39 forks source link

Linux Build Broken in Swift 5.3: kCFStringEncodingDOSLatinUS Not Found #13

Closed xanderdunn closed 4 years ago

xanderdunn commented 4 years ago

SWCompression 4.5.5. Ubuntu 18.04.

I tested this on Swift 5.3 Release:

$ which swift
/home/xander/swift-5.3-RELEASE-ubuntu18.04/usr/bin/swift
$ swift --version
Swift version 5.3 (swift-5.3-RELEASE)
Target: x86_64-unknown-linux-gnu

and Swift for Tensorflow 0.10 (based on Swift dev trunk):

$ which swift
/home/xander/swift-tensorflow-RELEASE-0.10-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift
$ swift --version
Swift version 5.3-dev (LLVM 55d27a5828, Swift 6a5d84ec08)
Target: x86_64-unknown-linux-gnu

Error:

$ swift build
warning: dependency 'Metaprogramming' is not used by any target
.build/checkouts/SWCompression/Sources/ZIP/ByteReader+Zip.swift:36:86: error: cannot find 'kCFStringEncodingDOSLatinUS' in scope
        static let cp437Encoding: CFStringEncoding = UInt32(truncatingIfNeeded: UInt(kCFStringEncodingDOSLatinUS))
                                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
[73/91] Compiling a_bitstr.c
xanderdunn commented 4 years ago

It appears this is specific to Swift 5.3. I successfully complied it on 5.2.5. Note that I still can't use it in my project because Swift for Tensorflow is built off trunk, which includes 5.3 changes.

I see the CI for Linux only goes up to Swift 5.2 right now, so that explains why CI is passing.

tsolomko commented 4 years ago

Thank you for bringing this up. It appears that in Swift 5.3 something has been changed in how CoreFoundation is imported into Swift on Linux or something like that. It is maybe related to this thread on swift forums: https://forums.swift.org/t/formalizing-the-unavailability-of-core-foundation/40216

Anyway, I fixed this in 2c46351a4463d8822a9ed48c2c7ebde8d96bf1ca, and it seems to be successfully compiling in CI (yes, I also added Swift 5.3 builds in CI). Hopefully, I will publish a new release containing this change soon. There is another issue (https://github.com/Carthage/Carthage/issues/3019) impacting SWCompression which I need to add a workaround for first.

P.S. I can only hope that one day Apple will manage to release a new Swift version without introducing subtle unannounced changes which break compilation of other projects...

tsolomko commented 4 years ago

I've released an update to SWCompression (4.5.6) which fixes this issue.