Cannot find `ArchiveByteStream` in scope

I'm currently trying to decompress a received .zip file from the backend and while researching I found the native library called AppleArchive. I've imported the library and tried the code described here but I get the following error:

Also if i go into the library itself only one method shows up:

public func __assert_rtn(_: UnsafePointer<CChar>!, _: UnsafePointer<CChar>!, _: Int32, _: UnsafePointer<CChar>!) -> Never

Tested on Xcode 13.2 on a project with minimum deployment of iOS 15.0

Edit Tested it again by changing the build target to be a real device and it works!

Questions:

  1. Can this library be used to unarchive .zip files?
  2. How can AppleArchive be used on a simulator device?

Replies

The Xcode Developer Documentation has a detailed explanations of Apple Archive, including:

  • Decompressing Single Files
  • Decompressing and Extracting an Archived Directory
  • Decompressing and Parsing an Archived String

Your example code snippets may have become outdated (or may just be incomplete), but it builds cleanly for me, except for the handling of the "defer" statements.

import AppleArchive
import System

func testDecompressStream(readFileStream: ArchiveByteStream) {
    guard let decompressStream = ArchiveByteStream.decompressionStream(readingFrom: readFileStream) else {
        return
    }
    defer {
        try? decompressStream.close()
    }
}

Xcode 13.2 (13C90)

  • The defer statements just need some code after them, to action the decompressed data.

  • When you tested this code did you chose a simulator or a real device?

Add a Comment

When you tested this code did you chose a simulator or a real device?

That’s key. There’s a known issue with Apple Archive when building for the simulator. See this thread.

Share and Enjoy

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

  • I saw it before I started this thread but that one was written 1 year ago and no info was given as to the status of the bug. Apple also introduced Apple Encrypted Archive this year at WWDC21 so I thought that with the new update this issue was fixed as well and something else was the problem

Add a Comment

When you tested this code did you chose a simulator or a real device?

The original question did not specify a platform.
I tested on macOS.