ios-hot-reload-3.mov
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.
- 🌟 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
- Xcode Command Line Tools
fswatch
(can be installed via Homebrew:brew install fswatch
)tuist
(for projects using Tuist)
- Clone this repository:
git clone https://github.com/aose-yuu/ios-hot-reload.git
- Navigate to the cloned directory:
cd ios-hot-reload
- Run the install script:
sudo ./install.sh
The script will be installed to /usr/local/bin
and will be available system-wide.
- Reload
.zshrc
Please restart your terminal or run source ~/.zshrc
to apply changes.
- To remove ios-hot-reload from your system
run the following command:
ios-hot-reload uninstall
- Reload
.zshrc
Please restart your terminal or run source ~/.zshrc
to apply changes.
- Navigate to your Xcode project's root directory in the terminal.
- 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.
- 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.
Contributions to improve the script are welcome. Please feel free to submit a Pull Request.
This script is released under the MIT License. See the LICENSE file for details.
Made with ❤️ by aose-yuu