AppleSimulatorUtils

repository·master·Indexed 20 days ago

https://github.com/wix/applesimulatorutils

A collection of utilities for managing and interacting with Apple simulators. Features include setting app permissions, managing biometric authentication (Face ID/Touch ID), and listing available devices. The tool is available as the applesimutils CLI via Homebrew.

Tokens
2.7K
Snippets
11
Records
14
Agent score
72%

What's inside AppleSimulatorUtils

  1. Replace deprecated --setLocation command with xcrun simctl location

    master

    The --setLocation command in AppleSimulatorUtils is deprecated. Use the official Apple xcrun simctl location command instead. For detailed usage and available flags, run xcrun simctl location --help.

    # Instead of using AppleSimulatorUtils --setLocation
    xcrun simctl location <device> <latitude> <longitude>
  2. Manually update Homebrew SHA256 hashes

    master

    Because the release script fails to update Homebrew hashes correctly on the first try, you must manually update the applesimutils.rb formula in the wix-incubator/homebrew-brew repository.

    1. Locate the SHA256 hashes for the assets (e.g., AppleSimulatorUtils-0.9.12.tar.gz) under the Assets section of your new GitHub release.
    2. Open the formula file: applesimutils.rb in the wix-incubator/homebrew-brew repository.
    3. Update the sha256 fields with the correct values found on GitHub.
  3. Release a new version of AppleSimulatorUtils

    master

    To publish a new version, follow these steps in order:

    1. Pre-flight Check: Ensure you have direct push access to the master branch and that all features are committed and tested.
    2. Run the Release Script: Execute the release script with the target version number. This will open your default Markdown editor for release notes. Important: You must completely quit the editor (e.g., Xcode) after writing your notes for the script to proceed.
    3. Update Homebrew Hashes: Due to a known bug, the release script does not update Homebrew hashes correctly on the first attempt. You must manually update the SHA256 hashes in the Homebrew formula immediately after the GitHub release is live.
    4. Final Verification: Verify the installation via Homebrew.
    ./releaseVersion.sh <YOUR_VERSION>
    # e.g.
    ./releaseVersion.sh 0.9.12
  4. Fix a failed Homebrew formula update during release

    master

    If the Homebrew formula update fails (for example, due to a wrong hash or bad URL), the release might be left in a broken or partial state. To unblock the process, commit an empty change to trigger a retry, then re-run the release script.

    git commit --allow-empty -m "Trigger retry for release <version>"
    # Then re-run the release script
  5. Troubleshooting regressions in deprecated AppleSimulatorUtils commands

    master
    While most deprecated commands in AppleSimulatorUtils still function, they may exhibit regressions when used with newer versions of iOS or Xcode. If you encounter unexpected behavior or errors, the recommended solution is to migrate to the official xcrun simctl commands, as they are maintained by Apple and are more up-to-date.
  6. Troubleshoot applesimutils installation

    master

    If you encounter issues installing or running applesimutils, try the following steps:

    1. Command Line Tools: Ensure your Xcode Command Line Tools are updated via the macOS System Update preference pane.
    2. Homebrew Tap Conflicts: If Homebrew reports a conflict in the wix/brew tap, reset it:
      brew untap wix/brew && brew tap wix/brew
    3. General Health: Run brew doctor and resolve any reported issues or warnings.
  7. Set app permissions on a simulator

    master

    You can grant or revoke specific permissions for an app bundle on a simulator. Using --setPermissions will automatically restart SpringBoard to ensure the changes take effect. You can target a simulator using its UDID (--byId) or its name (--byName).

    # Set permissions using UDID
    applesimutils --byId <simulator UDID> --bundle <bundle identifier> --setPermissions "<permission1>, <permission2>, ..."
    
    # Set permissions using Name and OS
    applesimutils --byName <simulator name> --byOS <simulator OS> --bundle <bundle identifier> --setPermissions "<permission1>, <permission2>, ..."
  8. Manage biometric authentication

    master

    The utility provides commands to manage biometric (Face ID/Touch ID) states on booted simulators. You can enroll biometrics or simulate successful/failed authentication attempts.

    # Enable/Disable biometric enrollment on a booted simulator
    applesimutils --booted --biometricEnrollment YES
    
    # Simulate a successful biometric match
    applesimutils --booted --biometricMatch
    
    # Simulate a failed biometric match
    applesimutils --booted --biometricNonmatch
  9. Replace deprecated --setPermissions options with xcrun simctl privacy

    master

    The following --setPermissions options in AppleSimulatorUtils are deprecated. You should replace them with the corresponding xcrun simctl privacy commands to ensure compatibility with newer versions of iOS and Xcode.

    AppleSimulatorUtils optionxcrun simctl privacy equivalent
    calendarcalendar
    contactscontacts
    locationlocation
    photosphotos
    medialibrarymedia-library
    microphonemicrophone
    motionmotion
    remindersreminders
    sirisiri
    # Example replacement for setting media library permissions
    # Instead of using AppleSimulatorUtils --setPermissions medialibrary
    xcrun simctl privacy media-library <device> <status>
  10. Reference: applesimutils CLI options

    master

    The following flags are available for filtering and executing simulator tasks:

    --byId, -id                   Filters simulators by unique device identifier (UDID)
    --byName, -n                  Filters simulators by name
    --byType, -t                  Filters simulators by device type
    --byOS, -o                    Filters simulators by operating system
    --booted, -bt                 Filters simulators by booted status
    
    --list, -l                    Lists available simulators
    --bundle, -b                  The app bundle identifier
    --maxResults                  Limits the number of results returned from --list
    --fields                      Comma-separated list of fields to include in --list output (e.g. "udid,os,identifier")
    
    --setPermissions, -sp         Sets the specified permissions and restarts SpringBoard for the changes to take effect
    --clearKeychain, -ck          Clears the simulator's keychain
    --clearMedia, -cm             Clears the simulator's media
    --restartSB, -sb              Restarts SpringBoard
    
    --biometricEnrollment, -be    Enables or disables biometric (Face ID/Touch ID) enrollment.
    --biometricMatch, -bm           Approves a biometric authentication request with a matching biometric feature (e.g. face or finger)
    --biometricNonmatch, -bnm      Fails a biometric authentication request with a non-matching biometric feature (e.g. face or finger)
    
    --version, -v                 Prints version
    --help, -h                    Prints usage