---
title: "init(compressedContentsOfDirectoryAtURL:)"
framework: xctest
role: symbol
role_heading: Initializer
path: "xctest/xctattachment/init(compressedcontentsofdirectoryaturl:)"
---

# init(compressedContentsOfDirectoryAtURL:)

Creates an attachment containing a zipped archive of an existing directory on disk.

## Declaration

```swift
convenience init(compressedContentsOfDirectoryAtURL url: URL)
```

## Parameters

- `url`: A file URL for a directory whose contents should be compressed.

## Discussion

Discussion Zips the contents of the provided directory and wraps the compressed output in an attachment with a uniformTypeIdentifier of "public.zip-archive". The attachment’s name property is set to the name of the zipped directory followed by an extension of ".zip". Available on macOS only.

## See Also

### Creating Attachments from Files and Folders

- [init(contentsOfFileAtURL:)](xctest/xctattachment/init(contentsoffileaturl:).md)
- [init(contentsOfFileAtURL:uniformTypeIdentifier:)](xctest/xctattachment/init(contentsoffileaturl:uniformtypeidentifier:).md)
