<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UniformTypeIdentifiers",
  "identifier" : "/documentation/UniformTypeIdentifiers/UTType-swift.struct/init(filenameExtension:conformingTo:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Uniform Type Identifiers",
      "UniformTypeIdentifiers"
    ],
    "preciseIdentifier" : "s:22UniformTypeIdentifiers6UTTypeV17filenameExtension12conformingToACSgSS_ACtcfc"
  },
  "title" : "init(filenameExtension:conformingTo:)"
}
-->

# init(filenameExtension:conformingTo:)

Creates a type based on a filename extension and an existing supertype that it conforms to.

```
init?(filenameExtension: String, conformingTo supertype: UTType = .data)
```

## Parameters

`filenameExtension`

The filename extension.

`supertype`

Another type that the resulting type must conform to; for example, [`UTTypeData`](/documentation/UniformTypeIdentifiers/UTTypeData) or [`UTTypePackage`](/documentation/UniformTypeIdentifiers/UTTypePackage).

## Discussion

If the system finds no types with the provided filename extension and conformance, but the inputs are otherwise valid, it may provide a dynamic type. The initializer returns `nil` if the parameters aren’t valid.

This initializer is equivalent to calling:

```swift
UTType(tag: filenameExtension,
       tagClass: .filenameExtension,
       conformingTo: supertype)
```

To get the type of a file on disk, use <doc://com.apple.documentation/documentation/Foundation/URLResourceValues/contentType>.

> Important:
> You can’t always derive the type of a file system item based solely on its filename extension.

A type depends on other attributes in addition to the filename extension, including whether the item is a directory.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)