Skip to content

JordanCoin/ios-skills-collection / skills/conorluddy--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.

scripts/clipboard.py

View on GitHub
#!/usr/bin/env python3
"""
iOS Simulator Clipboard Manager

Copy text to simulator clipboard for testing paste flows.
Optimized for minimal token output.

Usage: python scripts/clipboard.py --copy "text to copy"
"""

import argparse
import subprocess
import sys

from common import resolve_udid


class ClipboardManager:
    """Manages clipboard operations on iOS simulator."""

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

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

    def copy(self, text: str) -> bool:
        """
        Copy text to simulator clipboard.

        Args:
            text: Text to copy to clipboard

        Returns:
            Success status
        """
        cmd = ["xcrun", "simctl", "pbcopy"]

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

        cmd.append(text)

        try:
            subprocess.run(cmd, capture_output=True, check=True)
            return True
        except subprocess.CalledProcessError:
            return False


def main():
    """Main entry point."""
    parser = argparse.ArgumentParser(description="Copy text to iOS simulator clipboard")
    parser.add_argument("--copy", required=True, help="Text to copy to clipboard")
    parser.add_argument(
        "--udid",
        help="Device UDID (auto-detects booted simulator if not provided)",
    )
    parser.add_argument("--test-name", help="Test scenario name for tracking")
    parser.add_argument("--expected", help="Expected behavior after paste")

    args = parser.parse_args()

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

    # Create manager and copy text
    manager = ClipboardManager(udid=udid)

    if manager.copy(args.copy):
        # Token-efficient output
        output = f'Copied: "{args.copy}"'

        if args.test_name:
            output += f" (test: {args.test_name})"

        print(output)

        # Provide usage guidance
        if args.expected:
            print(f"Expected: {args.expected}")

        print()
        print("Next steps:")
        print("1. Tap text field with: python scripts/navigator.py --find-type TextField --tap")
        print("2. Paste with: python scripts/keyboard.py --key return")
        print("   Or use Cmd+V gesture with: python scripts/keyboard.py --key cmd+v")

    else:
        print("Failed to copy text to clipboard")
        sys.exit(1)


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