<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecStaticCodeCreateWithPathAndAttributes(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecStaticCodeCreateWithPathAndAttributes"
  },
  "title" : "SecStaticCodeCreateWithPathAndAttributes(_:_:_:_:)"
}
-->

# SecStaticCodeCreateWithPathAndAttributes(_:_:_:_:)

Creates a static code object representing the code at a specified file system path using an attributes dictionary.

```
func SecStaticCodeCreateWithPathAndAttributes(_ path: CFURL, _ flags: SecCSFlags, _ attributes: CFDictionary, _ staticCode: UnsafeMutablePointer<SecStaticCode?>) -> OSStatus
```

## Parameters

`path`

A URL identifying the location on disk of the code for which you want a static code object. For bundles, pass a URL to the root directory of the bundle. For single files, pass a URL to the file. If you pass a URL to the main executable of a bundle, the bundle as a whole is generally recognized. Only absolute paths should be used.

`flags`

Optional flags; see [`SecCSFlags`](/documentation/Security/SecCSFlags) for possible values. Pass [`kSecCSDefaultFlags`](/documentation/Security/SecCSFlags/kSecCSDefaultFlags) for standard behavior.

`attributes`

A <doc://com.apple.documentation/documentation/CoreFoundation/CFDictionary> containing additional attributes of the requested code. Possible values are defined in [Code Attributes](/documentation/Security/code-attributes).

`staticCode`

On return, the static code object representing the code you specified in the `path` parameter.

## Return Value

A result code. See [Code Signing Services Result Codes](/documentation/Security/code-signing-services-result-codes).

## Discussion

A static code object is not inherently linked to running code in the system.

It is possible to create a static code object from unsigned code. Although most uses of such an object cause the function to fail and return the result code [`errSecCSUnsigned`](/documentation/Security/errSecCSUnsigned) error, you can call the [`SecCodeCopyPath(_:_:_:)`](/documentation/Security/SecCodeCopyPath(_:_:_:)) and [`SecCodeCopySigningInformation(_:_:_:)`](/documentation/Security/SecCodeCopySigningInformation(_:_:_:)) functions for such objects.

## See Also

[`SecCodeCopyPath(_:_:_:)`](/documentation/Security/SecCodeCopyPath(_:_:_:))

Retrieves the location on disk of signed code, given a code or static code object.

[`SecCodeCopyStaticCode(_:_:_:)`](/documentation/Security/SecCodeCopyStaticCode(_:_:_:))

Returns a static code object representing the on-disk version of the given running code.



---

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)