react-native-community / cli

React Native command line tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve the developer experience of specifying device/simulator

warrenfalk opened this issue · comments

Feature Description

Objective: Implement a mechanism allowing developers to specify personal preferences for devices/simulators without altering shared, version-controlled files.

Current Challenge: Developers often modify package.json to set device/simulator preferences, like so:

  "scripts": {
    "ios": "react-native run-ios --simulator 'iPad Air'"
  }

Such modifications, while useful for individual workflow (especially for those using multiple machines or working on various projects), can lead to unintended changes in shared files. This request aims to create a more flexible, non-disruptive way to set these preferences.

Proposed Implementations

Primary Suggestion: Utilize environment variables for local configuration of device and simulator preferences.

Environment Variables Example:

  • PREFERRED_IOS_DEVICES: A comma-separated list of devices (identified by UDID or name).

Preference Hierarchy:

  1. Command-line Arguments: Have the highest priority. If specified, these override other settings.
  2. Environment Variables: If no arguments are provided, the system should match an attached device or simulator (booted or not) from the environment variable list.
  3. Default Logic: If no matches are found in the above steps, revert to the standard logic (selecting the first attached device, booted simulator, or other fallbacks).

Extension to Android: A similar approach could be implemented for Android environments.

Related Issues

None identified.


hey @warrenfalk! That sounds reasonable, and I think we can implement this! Would you like do it?

@szymonrybczak, Yes, I'll send a PR

(TIL if you put the issue number in your commit, then all amends to that commit will generate a comment on the issue 🤦🏻‍♂️ even if on a fork of the repo)