Skip to content

Structure

URI

A type for constructing and manipulating (most) Uniform Resource Indicators.
struct URI

Overview

Warning

This is NOT the same as Foundation’s URL type!

Can be used to both parse strings containing well-formed URIs and to generate such strings from a set of individual URI components.

Use of this type is (gently, for now) discouraged. Consider using Foundation’s URL and/or URLComponents types instead. See below for details.

URI is for URLs, not URIs

Thanks to both backwards compatibility requirements and name collision concerns, this type, despite its name, does not actually represent a generic Uniform Resource Identifier as defined by RFC 3986. In particular, the underlying implementation is currently based on Foundation’s URLComponents type, whose semantics are inconsistent between different methods; in addition, its behavior has differed drastically between the macOS and Linux implementations for most of its existence, and continues to do so in Swift 5.9. This is not expected to be remedied until the swift-foundation package reaches a 1.0 release, which as of this writing will not for quite some time yet). In short, instances of URI may not always behave as expected according to either the spec or what Foundation does.

Topics

Structures

  • URI.Scheme
    A URI scheme, as defined by RFC 3986 § 3.1 and [RFC 7595].

Initializers

Instance Properties

Instance Methods

  • encode(to:)
    Encodes this value into the given encoder.

Relationships

Conforms To

  • Swift.CustomStringConvertible
  • Swift.Decodable
  • Swift.Encodable
  • Swift.Equatable
  • Swift.ExpressibleByExtendedGraphemeClusterLiteral
  • Swift.ExpressibleByStringInterpolation
  • Swift.ExpressibleByStringLiteral
  • Swift.ExpressibleByUnicodeScalarLiteral
  • Swift.Hashable
  • Swift.Sendable
  • Swift.SendableMetatype