I am trying to create my own content blocker on iOS. I was wanting to create separate json lists for different types of content (tracking, ads, adult sites, etc). I came across this https://github.com/calebhicks/ios-safari-content-blocking which stated you could create an array of "attachments" instead of relying on the singular "blockerList" json file.
func beginRequest(with context: NSExtensionContext) {
var jsonFiles:Array<NSItemProvider> = Array()
let attachment = NSItemProvider(contentsOf: Bundle.main.url(forResource: "blockerList", withExtension: "json"))!
jsonFiles.append(attachment)
let attachment2 = NSItemProvider(contentsOf: Bundle.main.url(forResource: "testList", withExtension: "json"))!
jsonFiles.append(attachment2)
let item = NSExtensionItem()
item.attachments = jsonFiles
context.completeRequest(returningItems: [item], completionHandler: nil)
}
Most of this code is the default from the Content Blocker Extension setup, but what I have added is the jsonFiles array which attachment and attachment2 are placed in. When this is run, only one of the two rule sets is loaded, never a combination of the two. Any ideas on why only one ruleset is loaded?
You can combine two JSON rule files in to one file and use that file.