<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKContentRuleListStore/compileContentRuleList(forIdentifier:encodedContentRuleList:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKContentRuleListStore(im)compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:"
  },
  "title" : "compileContentRuleList(forIdentifier:encodedContentRuleList:completionHandler:)"
}
-->

# compileContentRuleList(forIdentifier:encodedContentRuleList:completionHandler:)

Compiles the specified JSON content into a new rule list and adds it to the current data store.

```
func compileContentRuleList(forIdentifier identifier: String!, encodedContentRuleList: String!, completionHandler: ((WKContentRuleList?, (any Error)?) -> Void)!)
```

## Parameters

`identifier`

A unique identifier for the new list. If a list with the specified identifier already exists in the store, this method overwrites the old rule list with the new content.

`encodedContentRuleList`

The JSON source for the new rule list. For information about how to format the JSON content, see <doc://com.apple.documentation/documentation/SafariServices/creating-a-content-blocker>.

`completionHandler`

A completion handler block to call after compilation finishes. This block has no return value and takes the following parameters:

- ruleList: The [`WKContentRuleList`](/documentation/WebKit/WKContentRuleList) object that encapsulates the compiled rules derived from the `encodedContentRuleList` parameter. This parameter is `nil` if an error occurs during compilation.
- error: `nil` on success, or an error object if a problem occurred.

## Discussion

---

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)