https://github.com/buresdv/applicationinspector
https://github.com/buresdv/applicationinspector
Last synced: 30 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/buresdv/applicationinspector
- Owner: buresdv
- Created: 2025-10-06T21:53:05.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2026-02-01T19:08:57.000Z (6 months ago)
- Last Synced: 2026-05-03T09:08:04.863Z (3 months ago)
- Language: Swift
- Size: 22.5 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# .app Bundles the Swift Way
Have you ever wanted to read an `.app`'s data, but it was too annoying?
Enter `ApplicationInspector`, the one-stop-shop for reading Application Bundles.
> [!NOTE]
> This library is still in development. We recommend that you use of the version tags to pin the version you will be using to prevent broken behavior.
## Usage
The library provides two objects, an `Application` struct, which represents an Application Bundle, and an `ApplicationInspector` class, which is used for reading all installed Applications.
### Initializing a standalone Application structure
To initialize and `Application` struct, use the provided initializer, passing in the complete URL of the Application Bundle:
```swift
try Application.init(from: URL)
```
The initializer for `Application` is throwable and provides the following errors:
```swift
/// The provided URL does not exist in the filesystem
case providedURLDoesNotExist(checkedPath: String)
/// The provided URL is not readable, there might be misconfigured permissions
case applicationExecutableNotReadable(checkedPath: String)
/// The provided URL exists and whatever it points to is readable, but it is not an Application Bundle
case couldNotReadBundle(applicationPath: String)
/// Could not read the information dictionary from the provided App Bundle. Either it is not readable, or it is not formatted correctly
case couldNotGetInfoDictionary
/// Could not get the name of the app from the provided Application Bundle
case couldNotGetMandatoryAppInformation(_ mandatoryInformation: MandatoryAppInformation)
```
Once an `Application` object is created, you gain access to the following metadata about the application:
- `name`: The name of the app
- `iconPath` (optional): Full path to the app's icon
- `iconImage` (optional): The app's icon in SwiftUI's `Image` format
### Reading the entire Applications folder
To read the entire Applications folder, initialize the `ApplicationInspector` class. You can specify whether to exclude system apps, like *Music*, *Mail*, and others, by specifying `excludeSystemApps` in the initializer:
```swift
let testApplicationInspector: ApplicationInspector = try await .init(excludeSystemApps: Bool)
```
The `ApplicationInspector` class defines a `installedApplications` property, which contains an array of the loaded Applications, represented by a `ApplicationsListingResult` typealias. This typealias contains an `Application` if the reading of that Application was successful, or an `Application.ApplicationInitializationError` if the reading of that application failed.
The initializer for `ApplicationInspector` is throwable and provides the following errors:
```swift
/// The library does not have permissions to read the Applications directory
case couldNotReadContentsOfApplicationsDirectory(error: Error)
```
## License
Unless otherwise specified or given my explicit permission, this software is licensed under [AGPLv3](https://www.gnu.org/licenses/agpl-3.0.html).