XCode build phases: run script in background (without blocking build)

后端 未结 3 494
渐次进展
渐次进展 2021-02-09 08:52

I\'d like to be able to run a script in the background (i.e. without blocking the build process) when I build and run an iOS application in the simulator. I\'ve tried osas

相关标签:
3条回答
  • 2021-02-09 09:02

    Incase you are still interested.

    These are the steps you need to follow: 1. Change the .sh extension of your script to .command 2. Rather than invoking /path/to/script.sh you now start using "open /path/to/script.command"

    Thats pretty much it.

    This will start a new terminal window and run the script you want in it.

    0 讨论(0)
  • 2021-02-09 09:19

    You could use post-actions of build in the schemes setting.

    "sleep 100&" works fine

    0 讨论(0)
  • 2021-02-09 09:27

    I had the same trouble with running a background script as part of the build phase but the following does work in my case. The script runs in the background while my app runs. Apparently, you have to redirect the standard output in addition to using the "&". Use the following format. (My script is located in directory '~/Desktop/splint_server/')

    ~/Desktop/splint_server/run.sh > ~/Desktop/splint_server/test 2>&1 &
    

    This runs an arbitrary script at ~/Desktop/splint_server/run.sh (put the path to your script there). The output is redirected to a log file called "test".

    More information about I/O redirection http://www.tldp.org/LDP/abs/html/io-redirection.html

    0 讨论(0)
提交回复
热议问题