XCode 构建阶段:在后台运行脚本(不阻塞构建) [英] XCode build phases: run script in background (without blocking build)

查看:30
本文介绍了XCode 构建阶段:在后台运行脚本(不阻塞构建)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在模拟器中构建和运行 iOS 应用程序时,我希望能够在后台运行脚本(即不阻塞构建过程).我已经尝试过 osascript/path/to/script &,并且还为一个单独的 shell 脚本做同样的工作,但都没有奏效;构建停止,我必须强制退出 XCode.

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 osascript /path/to/script &, and also backgrounding a separate shell script that does the same, but neither have worked; the build stops and I have to force quit XCode.

有什么想法吗?

推荐答案

我在运行后台脚本作为构建阶段的一部分时遇到了同样的问题,但以下对我的情况确实有效.当我的应用程序运行时,脚本在后台运行.显然,除了使用&"之外,您还必须重定向标准输出.使用以下格式.(我的脚本位于目录'~/Desktop/splint_server/')

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 &

这会在 ~/Desktop/splint_server/run.sh 运行任意脚本(将脚本的路径放在那里).输出被重定向到一个名为test"的日志文件.

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".

有关 I/O 重定向的更多信息 http://www.tldp.org/LDP/abs/html/io-redirection.html

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

这篇关于XCode 构建阶段:在后台运行脚本(不阻塞构建)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆