An open-source Swift package and command-line tool (btm-dumper
) to parse macOS Background Task Management (BTM) files (BackgroundItems-v*.btm
).
- macOS 10.15 or later
- Xcode 16 or later
-
Clone the repository:
git clone https://github.com/hewigovens/BTMParser.git cd BTMParser
-
Build the command-line tool:
swift build --target btm-dumper
-
Run the tool:
- To parse a specific BTM file:
Provide the path as a command-line argument.
swift run btm-dumper -f /path/to/your/BackgroundItems-vX.btm
- To parse a specific BTM file:
Provide the path as a command-line argument.
Note
You need Full Disk Access to read the path /private/var/db/com.apple.backgroundtaskmanagement/
.
The tool outputs the parsed data as a JSON object to standard output:
{
"itemsByUserID" : {
"770103FF-8EB4-455C-865F-6E4EAE62F8D7" : [
{
"bundleIdentifier" : "com.1password.1password",
"developerName" : "AgileBits Inc.",
"disposition" : 2,
"dispositionDetails" : "disabled allowed visible not notified",
"executablePath" : "/Applications/1Password.app/Contents/MacOS/1Password",
"generation" : 18,
"identifier" : "2.com.1password.1password",
"name" : "1Password",
"teamIdentifier" : "2BUA8C4S2C",
"type" : 2,
"typeDetails" : "app",
"url" : "file:///Applications/1Password.app/",
"uuid" : "55A31ED3-ADDE-4ABA-8BDC-19E88A31F18C"
}
]
},
"path" : "<BackgroundItems-vX.btm>"
}
You can add BTMParser
as a dependency to your own Swift package:
// In your Package.swift
dependencies: [
.package(url: "https://github.com/hewigovens/BTMParser.git", branch: "main")
],
targets: [
.target(
name: "YourTarget",
dependencies: ["BTMParser"]),
]
Then, import and use it:
import BTMParser
do {
// Parse a specific file
if let fileURL = URL(string: "/path/to/BackgroundItems-vX.btm") {
let btmData = try BTMParser.parse(path: fileURL)
print(btmData)
} else {
print("Invalid URL")
}
} catch let error as BTMParserError {
print("BTMParser Error: \(error)")
} catch {
print("An unexpected error occurred: \(error)")
}
BTMParser
is inspired by DumpBTM and is released under the same License.