DuckDuckGo is growing fast and we continue to expand our fully distributed team. We embrace diverse perspectives, and seek out passionate, self-motivated people, committed to our shared vision of raising the standard of trust online. If you are a senior software engineer capable in either iOS or Android, visit our careers page to find out more about our openings!
TrackerRadarKit
has one explicit dependency (https://github.com/apple/swift-argument-parser) that is automatically resolved when installing the swift package in Xcode. It can be added to an Xcode project as a swift package dependency or be used as an imported Swift package.
It can be built manually two ways:
- Build the
TrackerRadarKit
scheme by opening the Swift package in Xcode - Run
swift build -c release
to build a release binary
We use SwiftLint for enforcing Swift style and conventions, so you'll need to install it.
The Validator tool can be used to validate that Tracker Radar data can be parsed, transformed and compiled by WebKit's content rule list store. As such, it requires macos 10.13 to run.
To build, check out the code and run from the project root:
swift build
To run, execute the following from the project root:
.build/debug/Validator
We recommend the use of Swift Package Manager
In order to block content on the web view you need to compile a content rule list using Apple's WKContentRuleListStore, then apply the compiled rule list to WKUserContentController.
TrackerRadarKit allows you to generate this list using DuckDuckGo's Tracker Radar as source. The main structs you'll need to use to create a content rule lists are:
-
TrackerData - Tracker Radar JSON file encoded format;
-
ContentBlockerRulesBuilder - uses TrackerData to generate a list of ContentBlockerRules which can be encoded as a JSON source for the new rule list. To find more about the content rule list specifications, please visit Apple's documentation.
let trackerData: TrackerData = ...
let allowList: [String] = ...
let blockerBuilder = ContentBlockerRulesBuilder(trackerData: trackerData)
let rules = blockerBuilder.buildRules(withExceptions: allowList)
let data: Data
do {
data = try JSONEncoder().encode(rules)
} catch {
// Handle Error
}
let ruleList = String(data: data, encoding: .utf8)
DuckDuckGo is distributed under the Apache 2.0 license.