<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/ExpressibleByStringLiteral",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s26ExpressibleByStringLiteralP"
  },
  "title" : "ExpressibleByStringLiteral"
}
-->

# ExpressibleByStringLiteral

A type that can be initialized with a string literal.

```
protocol ExpressibleByStringLiteral : ExpressibleByExtendedGraphemeClusterLiteral
```

## Overview

The `String` and `StaticString` types conform to the
`ExpressibleByStringLiteral` protocol. You can initialize a variable or
constant of either of these types using a string literal of any length.

```
let picnicGuest = "Deserving porcupine"
```

# Conforming to ExpressibleByStringLiteral

To add `ExpressibleByStringLiteral` conformance to your custom type,
implement the required initializer.

## Topics

### Associated Types

[`associatedtype StringLiteralType : _ExpressibleByBuiltinStringLiteral`](/documentation/Swift/ExpressibleByStringLiteral/StringLiteralType)

A type that represents a string literal.

### Initializers

[`init(stringLiteral: Self.StringLiteralType)`](/documentation/Swift/ExpressibleByStringLiteral/init(stringLiteral:))

Creates an instance initialized to the given string value.

## Relationships

### Conforming Types

[`Substring`](/documentation/Swift/Substring)

[`String`](/documentation/Swift/String)

[`LocalizationValue`](/documentation/Swift/String/LocalizationValue)

[`StaticString`](/documentation/Swift/StaticString)

### Inherited By

[`ExpressibleByStringInterpolation`](/documentation/Swift/ExpressibleByStringInterpolation)

[`StringProtocol`](/documentation/Swift/StringProtocol)

### Inherits From

[`ExpressibleByExtendedGraphemeClusterLiteral`](/documentation/Swift/ExpressibleByExtendedGraphemeClusterLiteral)

[`ExpressibleByUnicodeScalarLiteral`](/documentation/Swift/ExpressibleByUnicodeScalarLiteral)

---

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)