The first way:

command + shift + N

Create an embedded target

Then create a Run script under the created target

This is done in the same way we normally execute scripts, by running script

The second way:

We select this option when creating target, which is the external build system

We see an external build configuration option in info

Among them:

  • Build Tool: execution mode
  • Arguments.run, clean, Archive, etc under Product in xcode
  • Directory: indicates the Directory, which is the path of the script

For example, we usually clone repository code through Git, can be in this way

Run it:

We realized that he was actually downloading the code. When we finished, we realized that a copy of the code had been cloned under directory

But how to execute the script? We put a shell script in the project directory

Check the terminal number:

Then write the following in shell.sh:

#! Echo "$@" >> /dev/ttys002 echo "execute shell script" >> /dev/ttys002Copy the code

Then run:

We find that the script executes and gets the parameters. This way, we can specify the script and parameters so that we are not restricted to the project

The third way:

We can add the run script directly to the xcode project, but the xcode project config file itself can execute the script, such as the following:

CMD = echo "${SRCROOT}--${SYMROOT}"
TTY=/dev/ttysoo1
Copy the code

The third option is to put all the scripts written in the Run script into the config file to make it more intuitive

In addition, the output of scripts configured in Run Script is in the compilation interface of Xcode, which is not intuitive, while in config we can specify our own terminal output, which is more intuitive