aose-yuu / ios-hot-reload

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iOS Hot Reload

ios-hot-reload-3.mov

License Issues Stars

A command-line tool for iOS development that provides hot reload functionality, automatically detecting changes in your Xcode project, rebuilding, and relaunching the app in the iOS Simulator.

✨ Features

  • 🌟 Can be called from anywhere, but only works in Xcode project directories
  • πŸ” Automatically detects Xcode project or workspace
  • πŸ‘€ Monitors file changes in the project directory
  • πŸš€ Automatically builds and runs the app when changes are detected
  • πŸ”’ Prevents multiple simultaneous builds
  • πŸ”™ Returns focus to the original application after building and running
  • πŸ—οΈ Works with both .xcodeproj and .xcworkspace project formats
  • πŸ”„ Executes tuist generate before each build to ensure up-to-date project files

πŸ”§ Prerequisites

  • Xcode Command Line Tools
  • fswatch (can be installed via Homebrew: brew install fswatch)
  • tuist (for projects using Tuist)

πŸ“¦ Installation

  1. Clone this repository:
git clone https://github.com/aose-yuu/ios-hot-reload.git
  1. Navigate to the cloned directory:
cd ios-hot-reload
  1. Run the install script:
sudo ./install.sh

The script will be installed to /usr/local/bin and will be available system-wide.

  1. Reload .zshrc

Please restart your terminal or run source ~/.zshrc to apply changes.

πŸ—‘ Uninstallation

  1. To remove ios-hot-reload from your system

run the following command:

ios-hot-reload uninstall
  1. Reload .zshrc

Please restart your terminal or run source ~/.zshrc to apply changes.

πŸš€ Usage

  1. Navigate to your Xcode project's root directory in the terminal.
  2. Run the command:
ios-hot-reload run

3.The script will start monitoring for file changes. Any changes in the project directory will trigger a tuist generate command, followed by a rebuild and relaunch of the app in the iOS Simulator.

πŸ“ Notes

  • The command will only work when run from the root directory of an Xcode project.
  • The script uses osascript, which may require privacy permissions. You may need to grant appropriate permissions in System Preferences > Security & Privacy > Privacy > Accessibility.
  • The script is set to ignore rapid successive changes (within 5 seconds) to prevent unnecessary rebuilds.
  • If you encounter any issues with app name or bundle ID detection, you may need to adjust the relevant parts of the script.
  • The script now includes a tuist generate step before each build. Ensure that your project is set up to use Tuist if you want to take advantage of this feature.

🀝 Contributing

Contributions to improve the script are welcome. Please feel free to submit a Pull Request.

πŸ“„ License

This script is released under the MIT License. See the LICENSE file for details.

Made with ❀️ by aose-yuu

About

License:MIT License


Languages

Language:Shell 100.0%