<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CarPlay",
  "identifier" : "/documentation/CarPlay/CPInterfaceController/setRootTemplate(_:animated:completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "CarPlay"
    ],
    "preciseIdentifier" : "c:objc(cs)CPInterfaceController(im)setRootTemplate:animated:completion:"
  },
  "title" : "setRootTemplate(_:animated:completion:)"
}
-->

# setRootTemplate(_:animated:completion:)

Sets the root template of the navigation hierarchy.

```
func setRootTemplate(_ rootTemplate: CPTemplate, animated: Bool, completion: ((Bool, (any Error)?) -> Void)? = nil)
```

```
func setRootTemplate(_ rootTemplate: CPTemplate, animated: Bool) async throws -> Bool
```

## Parameters

`rootTemplate`

The template to use as the root of a new navigation hierarchy.

`animated`

If <doc://com.apple.documentation/documentation/Swift/true>, CarPlay animates the presentation of the template. CarPlay ignores this flag when there isn’t an existing navigation hierarchy to replace.

`completion`

The closure CarPlay calls after it presents the template.

## Discussion

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> func setRootTemplate(_ rootTemplate: CPTemplate, animated: Bool) async throws -> Bool
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

If you set a root template when a navigation hierarchy already exists, CarPlay replaces the entire hierarchy.

CarPlay calls `completion` after it presents the template. The Boolean parameter is <doc://com.apple.documentation/documentation/Swift/true> when the presentation succeeds; otherwise, it’s <doc://com.apple.documentation/documentation/Swift/false> and CarPlay provides an error that describes the failure. CarPlay throws an exception if the presentation fails and you don’t provide a closure.

---

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)