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

# SecRequirementCreateWithStringAndErrors(_:_:_:_:)

Creates a code requirement object by compiling a valid text representation of a code requirement and returns detailed error information in the case of failure.

```
func SecRequirementCreateWithStringAndErrors(_ text: CFString, _ flags: SecCSFlags, _ errors: UnsafeMutablePointer<Unmanaged<CFError>?>?, _ requirement: UnsafeMutablePointer<SecRequirement?>) -> OSStatus
```

## Parameters

`text`

The text form of a code requirement.

`flags`

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

`errors`

On return, if the function call fails and returns a result code other than `errSecSuccess`, points to an error object further describing the nature and circumstances of the failure. Use the <doc://com.apple.documentation/documentation/CoreFoundation/CFErrorCopyUserInfo(_:)> function to retrieve the user info dictionary from the error object. See [User Info Dictionary Error Keys](/documentation/Security/user-info-dictionary-error-keys) for possible values. Pass `NULL` if you do not want this information. In Objective-C, call the <doc://com.apple.documentation/documentation/CoreFoundation/CFRelease> function to release this object when you are finished with it.

`requirement`

On return, contains a code requirement object that implements the conditions described in the text.

## Return Value

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

## Discussion

The advantage of this function over [`SecRequirementCreateWithString(_:_:_:)`](/documentation/Security/SecRequirementCreateWithString(_:_:_:)) is that if there are any errors in the text string you pass in the `text` parameter, this function returns the syntax errors generated by the parser. These errors are in plain English and can be displayed to a user if it would be useful to do so. Code requirements and the code signing requirement language are documented in [Code Signing Guide](https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40005929).

If you use the [`SecRequirementCreateWithStringAndErrors(_:_:_:_:)`](/documentation/Security/SecRequirementCreateWithStringAndErrors(_:_:_:_:)) function to create a code requirement object from a text string and later use the [`SecRequirementCopyString(_:_:_:)`](/documentation/Security/SecRequirementCopyString(_:_:_:)) function to convert the object back to a string, the reconstituted text may differ in formatting, contain different source comments, and perform its validation functions in different order from the original. However, it is guaranteed that that the reconstituted text is functionally identical to the original. That is, recompiling the text using [`SecRequirementCreateWithString(_:_:_:)`](/documentation/Security/SecRequirementCreateWithString(_:_:_:)) will produce a code requirement object that behaves identically to the first one you created.

---

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)