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

# init(identifier:allowUndeclared:)

Create a type given a type identifier, optionally allowing identifiers that do not have an
active declaration on the current system.

```
init?(identifier: String, allowUndeclared: Bool)
```

## Parameters

`identifier`

The type identifier.

`allowUndeclared`

Whether to return an object if no type with the provided identifier
is known to the system.

## Return Value

A type object, or `nil` if the input `identifier` was not a
Uniform Type Identifier.

## Discussion

When `allowUndeclared` is `true`, this initializer can be used to obtain a type
object that keeps the “identity” of the input identifier even if no type with that
identifier is (currently) known to the system. In that case, the type is neither dynamic
nor declared, and has no conformances or tags (or any other properties).

If a type with the input identifier is known to the system, or if the input identifier is in
the dynamic namespace, it returns the same type object that `typeWithIdentifier:` would
return.

If `allowUndeclared` is `false`, this initializer behaves identically to `UTType.init?(:)`
given the same identifier.

One may use this, for instance, to create a concrete type object using an identifier that
may have been obtained from another system, and round-trip it through a subsystem without
losing the identity of the type.

If the input `identifier` is not a valid Uniform Type Identifier, the initializer returns
`nil`. See https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html#//apple_ref/doc/uid/TP40001319-CH202-SW2

---

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)