Brotli compression causes dload to fail on iOS 15?

Brotli compression is documented as available in iOS 13+. But my experience is that if I try to use Brotli compression prior to iOS 16 that my app will suffer a dload failure trying to dynamically link against the Compression library.

I have solved this, sort of, by weak linking against libCompression, and check that the IOS version >= 16 prior to using .brotli

Here's how I'm using brotli:

let outputFilter = try OutputFilter(.compress,
                                    using: .brotli) { (data: Data?) -> Void in
    if let data {
        compressedData.append(data)
    }
}

(The above will cause a dload error on iOS 15)

Questions:

  1. Is this a known issue?
  2. Is there any better way to test weather .brotli is available than checking the iOS version? I have somewhat anecdotal evidence that the OS version may no be the full story.

Replies

[Oh, would you look at that, a question using the Compression tag that’s actually about Compression framework. First time ever!]

Brotli compression is documented as available in iOS 13+.

It is? Oh, yeah, it is on the Swift side. However, if you look at the C header you’ll see this:

COMPRESSION_BROTLI   = 0xB02,       // available starting … iOS 15.0

It seems that the Swift interface is missing an availability annotation on that case.

Is this a known issue?

I don’t know, but in situations like this I encourage you to file a bug regardless.

Please post your bug number, just for the record.

Is there any better way to test weather .brotli is available than checking the iOS version?

No. Well, yes, in that the availability annotations should be correct, but in cases where the availability annotations are wrong then the obvious fallback is the OS version.

I have somewhat anecdotal evidence that the OS version may no be the full story.

I’d be surprised if that were the case, but if you uncover anything new I’d appreciate you updating this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"