Skip to content

n0an/VivaDicta / .agents/skills/ios-simulator-skill

ios-simulator-skill

Verified

21 production-ready scripts for iOS app testing, building, and automation. Provides semantic UI navigation, build automation, accessibility testing, and simulator lifecycle management. Optimized for AI agents with minimal token output.

FileKindSize
SKILL.mdskill md9.9 KB
agents/openai.yamlconfig279 B
references/accessibility_checklist.mdmarkdown1.5 KB
references/idb_quick.mdmarkdown1.1 KB
references/simctl_quick.mdmarkdown1.3 KB
references/test_patterns.mdmarkdown1.6 KB
references/troubleshooting.mdmarkdown1.3 KB
scripts/accessibility_audit.pyexecutablescript10.0 KB
scripts/app_launcher.pyexecutablescript9.5 KB
scripts/app_state_capture.pyexecutablescript12.9 KB
scripts/build_and_test.pyexecutablescript11.1 KB
scripts/clipboard.pyexecutablescript2.6 KB
scripts/common/__init__.pyscript1.5 KB
scripts/common/cache_utils.pyscript8.1 KB
scripts/common/device_utils.pyscript13.5 KB
scripts/common/idb_utils.pyscript5.3 KB
scripts/common/screenshot_utils.pyscript10.0 KB
scripts/gesture.pyexecutablescript12.3 KB
scripts/keyboard.pyexecutablescript11.5 KB
scripts/log_monitor.pyexecutablescript14.6 KB
scripts/navigator.pyexecutablescript14.0 KB
scripts/privacy_manager.pyexecutablescript8.7 KB
scripts/push_notification.pyexecutablescript6.5 KB
scripts/screen_mapper.pyexecutablescript10.4 KB
scripts/sim_health_check.shexecutablescript7.7 KB
scripts/sim_list.pyexecutablescript8.9 KB
scripts/simctl_boot.pyexecutablescript8.6 KB
scripts/simctl_create.pyexecutablescript8.9 KB
scripts/simctl_delete.pyexecutablescript10.3 KB
scripts/simctl_erase.pyexecutablescript9.8 KB
scripts/simctl_shutdown.pyexecutablescript8.4 KB
scripts/simulator_selector.pyexecutablescript10.3 KB
scripts/status_bar.pyexecutablescript6.6 KB
scripts/test_recorder.pyexecutablescript10.6 KB
scripts/visual_diff.pyexecutablescript7.6 KB
scripts/xcode/__init__.pyscript378 B
scripts/xcode/builder.pyscript12.8 KB
scripts/xcode/cache.pyscript5.5 KB
scripts/xcode/config.pyscript5.4 KB
scripts/xcode/reporter.pyscript10.3 KB
scripts/xcode/xcresult.pyscript16.5 KB

scripts/privacy_manager.py

View on GitHub
#!/usr/bin/env python3
"""
iOS Privacy & Permissions Manager

Grant/revoke app permissions for testing permission flows.
Supports 13+ services with audit trail tracking.

Usage: python scripts/privacy_manager.py --grant camera --bundle-id com.app
"""

import argparse
import subprocess
import sys
from datetime import datetime

from common import resolve_udid


class PrivacyManager:
    """Manages iOS app privacy and permissions."""

    # Supported services
    SUPPORTED_SERVICES = {
        "camera": "Camera access",
        "microphone": "Microphone access",
        "location": "Location services",
        "contacts": "Contacts access",
        "photos": "Photos library access",
        "calendar": "Calendar access",
        "health": "Health data access",
        "reminders": "Reminders access",
        "motion": "Motion & fitness",
        "keyboard": "Keyboard access",
        "mediaLibrary": "Media library",
        "calls": "Call history",
        "siri": "Siri access",
    }

    def __init__(self, udid: str | None = None):
        """Initialize privacy manager.

        Args:
            udid: Optional device UDID (auto-detects booted simulator if None)
        """
        self.udid = udid

    def grant_permission(
        self,
        bundle_id: str,
        service: str,
        scenario: str | None = None,
        step: int | None = None,
    ) -> bool:
        """
        Grant permission for app.

        Args:
            bundle_id: App bundle ID
            service: Service name (camera, microphone, location, etc.)
            scenario: Test scenario name for audit trail
            step: Step number in test scenario

        Returns:
            Success status
        """
        if service not in self.SUPPORTED_SERVICES:
            print(f"Error: Unknown service '{service}'")
            print(f"Supported: {', '.join(self.SUPPORTED_SERVICES.keys())}")
            return False

        cmd = ["xcrun", "simctl", "privacy"]

        if self.udid:
            cmd.append(self.udid)
        else:
            cmd.append("booted")

        cmd.extend(["grant", service, bundle_id])

        try:
            subprocess.run(cmd, capture_output=True, check=True)

            # Log audit entry
            self._log_audit("grant", bundle_id, service, scenario, step)

            return True
        except subprocess.CalledProcessError:
            return False

    def revoke_permission(
        self,
        bundle_id: str,
        service: str,
        scenario: str | None = None,
        step: int | None = None,
    ) -> bool:
        """
        Revoke permission for app.

        Args:
            bundle_id: App bundle ID
            service: Service name
            scenario: Test scenario name for audit trail
            step: Step number in test scenario

        Returns:
            Success status
        """
        if service not in self.SUPPORTED_SERVICES:
            print(f"Error: Unknown service '{service}'")
            return False

        cmd = ["xcrun", "simctl", "privacy"]

        if self.udid:
            cmd.append(self.udid)
        else:
            cmd.append("booted")

        cmd.extend(["revoke", service, bundle_id])

        try:
            subprocess.run(cmd, capture_output=True, check=True)

            # Log audit entry
            self._log_audit("revoke", bundle_id, service, scenario, step)

            return True
        except subprocess.CalledProcessError:
            return False

    def reset_permission(
        self,
        bundle_id: str,
        service: str,
        scenario: str | None = None,
        step: int | None = None,
    ) -> bool:
        """
        Reset permission to default.

        Args:
            bundle_id: App bundle ID
            service: Service name
            scenario: Test scenario name for audit trail
            step: Step number in test scenario

        Returns:
            Success status
        """
        if service not in self.SUPPORTED_SERVICES:
            print(f"Error: Unknown service '{service}'")
            return False

        cmd = ["xcrun", "simctl", "privacy"]

        if self.udid:
            cmd.append(self.udid)
        else:
            cmd.append("booted")

        cmd.extend(["reset", service, bundle_id])

        try:
            subprocess.run(cmd, capture_output=True, check=True)

            # Log audit entry
            self._log_audit("reset", bundle_id, service, scenario, step)

            return True
        except subprocess.CalledProcessError:
            return False

    @staticmethod
    def _log_audit(
        action: str,
        bundle_id: str,
        service: str,
        scenario: str | None = None,
        step: int | None = None,
    ) -> None:
        """Log permission change to audit trail (for test tracking).

        Args:
            action: grant, revoke, or reset
            bundle_id: App bundle ID
            service: Service name
            scenario: Test scenario name
            step: Step number
        """
        # Could write to file, but for now just log to stdout for transparency
        timestamp = datetime.now().isoformat()
        location = f" (step {step})" if step else ""
        scenario_info = f" in {scenario}" if scenario else ""
        print(
            f"[Audit] {timestamp}: {action.upper()} {service} for {bundle_id}{scenario_info}{location}"
        )


def main():
    """Main entry point."""
    parser = argparse.ArgumentParser(description="Manage iOS app privacy and permissions")

    # Required
    parser.add_argument("--bundle-id", required=True, help="App bundle ID (e.g., com.example.app)")

    # Action (mutually exclusive)
    action_group = parser.add_mutually_exclusive_group(required=True)
    action_group.add_argument(
        "--grant",
        help="Grant permission (service name or comma-separated list)",
    )
    action_group.add_argument(
        "--revoke", help="Revoke permission (service name or comma-separated list)"
    )
    action_group.add_argument(
        "--reset",
        help="Reset permission to default (service name or comma-separated list)",
    )
    action_group.add_argument(
        "--list",
        action="store_true",
        help="List all supported services",
    )

    # Test tracking
    parser.add_argument(
        "--scenario",
        help="Test scenario name for audit trail",
    )
    parser.add_argument("--step", type=int, help="Step number in test scenario")

    # Device
    parser.add_argument(
        "--udid",
        help="Device UDID (auto-detects booted simulator if not provided)",
    )

    args = parser.parse_args()

    # List supported services
    if args.list:
        print("Supported Privacy Services:\n")
        for service, description in PrivacyManager.SUPPORTED_SERVICES.items():
            print(f"  {service:<15} - {description}")
        print()
        print("Examples:")
        print("  python scripts/privacy_manager.py --grant camera --bundle-id com.app")
        print("  python scripts/privacy_manager.py --revoke location --bundle-id com.app")
        print("  python scripts/privacy_manager.py --grant camera,photos --bundle-id com.app")
        sys.exit(0)

    # Resolve UDID with auto-detection
    try:
        udid = resolve_udid(args.udid)
    except RuntimeError as e:
        print(f"Error: {e}")
        sys.exit(1)

    manager = PrivacyManager(udid=udid)

    # Parse service names (support comma-separated list)
    if args.grant:
        services = [s.strip() for s in args.grant.split(",")]
        action = "grant"
        action_fn = manager.grant_permission
    elif args.revoke:
        services = [s.strip() for s in args.revoke.split(",")]
        action = "revoke"
        action_fn = manager.revoke_permission
    else:  # reset
        services = [s.strip() for s in args.reset.split(",")]
        action = "reset"
        action_fn = manager.reset_permission

    # Execute action for each service
    all_success = True
    for service in services:
        if service not in PrivacyManager.SUPPORTED_SERVICES:
            print(f"Error: Unknown service '{service}'")
            all_success = False
            continue

        success = action_fn(
            args.bundle_id,
            service,
            scenario=args.scenario,
            step=args.step,
        )

        if success:
            description = PrivacyManager.SUPPORTED_SERVICES[service]
            print(f"✓ {action.capitalize()} {service}: {description}")
        else:
            print(f"✗ Failed to {action} {service}")
            all_success = False

    if not all_success:
        sys.exit(1)

    # Summary
    if len(services) > 1:
        print(f"\nPermissions {action}ed: {', '.join(services)}")

    if args.scenario:
        print(f"Test scenario: {args.scenario}" + (f" (step {args.step})" if args.step else ""))


if __name__ == "__main__":
    main()
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall