Skip to content

🕵️ Swift Package and command line application designed to scan Info.plist files in a specified directory and report the permissions requested by each file.

License

Notifications You must be signed in to change notification settings

ezefranca/check-permissions

Repository files navigation

check-permissions Swift

SPM compatible

Overview

The check-permissions is a Swift-based command line application designed to scan Info.plist files in a specified directory and report the permissions requested by each file. This tool is particularly useful for developers working with iOS projects, as it helps ensure that the necessary permissions are properly declared in the project directory.

Features

  • Recursive Scanning: Searches all subdirectories within the specified directory for Info.plist files.
  • Permission Detection: Identifies various permissions requested in Info.plist files, such as camera access, location services, and more.
  • User-Friendly Output: Provides a clear report of permissions for each Info.plist file found.

Installation

Prerequisites

  • macOS 12.0 or later
  • Swift 5.9 or later

Steps

  1. Clone the Repository:

    git clone https://github.com/ezefranca/check-permissions.git
    cd check-permissions
  2. Run the Installation Script:

    chmod +x install.sh
    ./setup.sh

The installation script will compile the tool and install it to /usr/local/bin, making it available globally as check-permissions.

Usage

Command-Line Options

  • --path <path>: Specify the path to the directory. This is a required argument.
  • --output <file> Specify the file to output the results to. (default is console output)
  • --verbose: Enable verbose output for more detailed information.
  • --help: Display the help message.

Example Usage

To scan a directory for Info.plist files and report the permissions:

check-permissions-cli --path <directory-path-to-scan>

To output to a report log file:

check-permissions-cli --path <directory-path-to-scan> --output report

To enable verbose output:

check-permissions-cli --path <directory-path-to-scan> --verbose

To display the help message:

check-permissions-cli --help

Sample Output

🚀 Starting the scanning process...
📂 Scanning directory: /Users/yourusername/Developer/YourProject
Found 3 Info.plist files.
File: /Users/yourusername/Developer/YourProject/ModuleA/Info.plist
 - NSCameraUsageDescription
 - NSLocationWhenInUseUsageDescription
File: /Users/yourusername/Developer/YourProject/ModuleB/Info.plist
 - NSMicrophoneUsageDescription
✅ Scanning process completed.

Using as a Package

To use the PermissionScan package in your Swift project, add it as a dependency in your Package.swift:

// swift-tools-version:5.4
import PackageDescription

let package = Package(
    name: "YourProject",
    platforms: [
        .iOS(.v15),
        .macOS(.v12),
        .watchOS(.v9),
        .tvOS(.v15),
        .visionOS(.v1)
    ],
    dependencies: [
        .package(url: "https://github.com/ezefranca/check-permissions", from: "0.0.4"),
    ],
    targets: [
        .target(
            name: "YourProject",
            dependencies: ["check-permissions-package"]),
    ]
)

Then import and use it in your code:

import check_permissions

let checker = PermissionChecker()
let report = checker.generateReport(for: URL(fileURLWithPath: "/path/to/your/project"))
for (plistPath, permissions) in report {
    print("File: \(plistPath)")
    for permission in permissions {
        print(" - \(permission)")
    }
}

Contributing

We welcome contributions to enhance the functionality of this tool. Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a clear description of your changes.

License

This project is licensed under the MIT License.

About

🕵️ Swift Package and command line application designed to scan Info.plist files in a specified directory and report the permissions requested by each file.

Topics

Resources

License

Stars

Watchers

Forks

Languages