▲ | drakenot 6 days ago | |||||||
ChatGPT 5> Without adding third-party dependencies, how can I compress a Data stream with zstd in Swift on an iPhone? (It auto-routed to its thinking model, took 25s) > Short answer: you can’t. iOS doesn’t ship a public zstd encoder/decoder. The system Compression and AppleArchive frameworks only expose lzfse, lz4, zlib/deflate, and lzma. So with only Apple SDKs, there’s no way to produce zstd-compressed bytes. > > Two practical paths: > 1. If zstd isn’t mandatory, use a built-in codec (lzfse or lz4 are fastest) via Compression’s streaming API. Example (pure Swift, no deps) that compresses an arbitrary byte stream: > > <code example> > 2. If zstd is mandatory, you must embed zstd yourself. That can mean: > - Vendoring the official C sources (libzstd) directly into your project and calling them via a tiny Swift wrapper/bridging header > - Statically linking a prebuilt libzstd.a you compile for iOS | ||||||||
▲ | djeastm 6 days ago | parent | next [-] | |||||||
Here's what I got with ChatGPT GPT-5, it must not have thought about it because it was near instantaneous: >On iOS, you can use Apple’s built-in Zstandard (zstd) compression API from the Compression framework — no third-party dependencies required. >Here’s how you can compress a Data stream with zstd: >... https://chatgpt.com/share/68976c8f-7ae0-8012-b7a8-58e016246d... | ||||||||
| ||||||||
▲ | hodgehog11 6 days ago | parent | prev [-] | |||||||
I think the useful takeaway here is that Top 1 operation is generally not a good idea, especially not for making judgements. This doesn't address the main points of the blog though. |