<!--
{
  "availability" : [
    "iOS: 8.0.0 - 27.0.0",
    "iPadOS: 8.0.0 - 27.0.0",
    "macCatalyst: 8.0.0 - 27.0.0",
    "macOS: 10.10.0 - 27.0.0",
    "tvOS: 9.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 2.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URL/appendingPathComponent(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation3URLV22appendingPathComponentyACSSF"
  },
  "title" : "appendingPathComponent(_:)"
}
-->

# appendingPathComponent(_:)

Returns a URL by appending the specified path component to self.

```
func appendingPathComponent(_ pathComponent: String) -> URL
```

## Parameters

`pathComponent`

The path component to add.

## Discussion

For file URLs, this method may perform file system I/O to determine if the path component is a directory, and, if so, it appends a trailing slash `/`. Use [`appendingPathComponent(_:isDirectory:)`](/documentation/Foundation/URL/appendingPathComponent(_:isDirectory:)) if you know the component’s file system object type in advance.

New code should use [`appending(path:directoryHint:)`](/documentation/Foundation/URL/appending(path:directoryHint:)) instead of this method.

---

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)