diff --git a/README.en-US.md b/README.en-US.md new file mode 100644 index 0000000..c5bdcc5 --- /dev/null +++ b/README.en-US.md @@ -0,0 +1,116 @@ +# XcodeSyncTools + +[A English version of this document can be found here](https://github.com/5SMNOONMS5/XcodeSyncTools/blob/master/README_EN.md) + +Synchronize built-in **Code-Snippets** and **File-Templates** across different computers in Xcode. + +## What are Code-Snippets and File-Templates? + +* [How to create Code-Snippets (Tutorial)](Tutorials/README_CS_CN.md) + +### Code-Snippets + +![](Imgs/git_xcode_sinppets.gif) + +* Returns a pre-written snippet based on custom keywords. + +### File-Template + +* [How to create File-Templates (Tutorial)](Tutorials/README_T_CN.md) + +![](Imgs/git_xcode_filetemplate.gif) + +* Similar concept to Code-Snippets, but can create pre-defined folder structures. + +## Project Workflow + +![](Imgs/diagram.png) + +* After performing a `git clone` to the local `XcodeSyncTools` directory, running the script will copy the files from the `XcodeSyncTools` directory to `/Users//Library/Developer/Xcode` (hereafter referred to as the Xcode directory). **If** you have [fsevents-tools](https://github.com/ggreer/fsevents-tools) running in the terminal, it will begin **monitoring** file changes in the Xcode directory and sync them back to the `XcodeSyncTools` directory. + +* While the primary management is done via git, the main tool being shared here is [fsevents-tools](https://github.com/ggreer/fsevents-tools). `fsevents-tools` utilizes OS X's [FSEvents](https://en.wikipedia.org/wiki/FSEvents) API to monitor changes to files or directories. Whenever any change occurs (add, delete, modify), it will **pipe** the execution to [rsync](https://zh.wikipedia.org/wiki/Rsync) to sync File-Templates and Code-Snippets from the Xcode directory back to the folders under `XcodeSyncTools`. This ensures that whenever a developer modifies template code in Xcode, the files in the `XcodeSyncTools` project change accordingly. Then, git is used to achieve synchronization. You can think of `fsevents-tools` as the OS X version of [inotify](https://zh.wikipedia.org/wiki/Inotify). + +## What happens if I don't use this project? + +* Nothing at all. Most developers create File-Templates or Code-Snippets directly within Xcode (see the tutorial sections: [Code-Snippets](Tutorials/README_CS_CN.md), [File-Template](Tutorials/README_T_CN.md)). Once created, you usually need to **manually** synchronize them. Using [fsevents-tools](https://github.com/ggreer/fsevents-tools) simply eliminates this manual step. + +> You can also pipe the output to any custom script (e.g., executing a githook or `git push`). + +## Getting Started + +* Clone the project. +* Run the script to copy files from the `CodeSnippets` and `Templates` folders to the corresponding Xcode directories. (If old versions exist, a backup copy will be created). + +* Note: Do not download the project as a ZIP file, as [fsevents-tools](https://github.com/ggreer/fsevents-tools) is added to this project as a [git Submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodule). + +```bash +# Step 1: Clone +# Via Http +git clone --depth 1 https://github.com/5SMNOONMS5/XcodeSyncTools.git + +# Step 2: Move working directory to XcodeSyncTools +cd XcodeSyncTools + +# Step 3: Sync all files, **only required for the first time**, use -w for monitoring thereafter +sh xcode-sync.sh -s + +# Step 4: Open Xcode and enjoy :) +``` + +## More + +```bash +sh xcode-sync.sh -h +``` + +## Monitoring + +```bash +sh xcode-sync.sh -w +``` + +## Having Your Own Code-Snippets and File-Templates + +The Code-Snippets and File-Templates in this project are mostly for personal use. If you want to use your own repository, you can modify the `path_source_url` variable inside `xcode-sync.sh`. + +![](Imgs/demo_change.png) + +After modifying, remember to run: + +```bash +sh xcode-sync.sh -c +``` + +Then enter the cycle of add, commit, and push to start using your own exclusive Code-Snippets and File-Templates. + +## Code-Snippets Keywords + +### II + +Type **II** (Initialization for most objects) + +![](Imgs/demo_ii.png) + +### FF + +Type **FF** (Custom Swift flag) + +![](Imgs/demo_ff.png) + +### MM + +Type **MM** (Mark) + +![](Imgs/demo_mm.png) + +### VV + +Type **VV** (View lifecycle) + +![](Imgs/demo_vv.png) + +## How to Use File-Templates + +Open Xcode and add a file as usual: File -> New -> File. Scroll to the bottom and you will find them. + +![](Imgs/demo_n.png)