<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTSourceCodeContext/init(location:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTSourceCodeContext(im)initWithLocation:"
  },
  "title" : "init(location:)"
}
-->

# init(location:)

Initializes a new instance with a call stack from the executing thread and a provided source code location.

```
convenience init(location: XCTSourceCodeLocation?)
```

## Parameters

`location`

A representation of a location in source code.

## Discussion

The system derives the call stack from `NSThread.callStackReturnAddresses.`

---

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)