如何从命令行运行Xcode构建应用程序(bash)

时间:2011-01-06 09:19:05

标签: iphone mobile

继续我的问题How to run an xcode project from bash?

我在构建目录中找到了构建的* .app,但我正在试图弄清楚如何让xcode打开它,因为它不能只是作为Mac OS X程序运行。

有什么想法吗?

感谢此帖:XCode Test Automation For IPhone

2 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,试图从构建我的xcode项目启动我的调试输出。我刚试验了以下

open ./prog.app&

似乎可以解决问题。

答案 1 :(得分:0)

我使用bash文件解决了我的问题,该文件使用rsync同步工作目录,然后使用AppleScript构建并运行项目。

sync.sh:

#!/bin/bash

# script for moving development files into xcode for building
developmentDirectory="/"
xcodeDirectory="/"
echo 'Synchronising...'
rsync -r $developmentDirectory $xcodeDirectory \
--exclude='.DS_Store' --exclude='.*' --exclude='utils/' --exclude='photos'
echo 'Synchronising Done at:'
echo $(date)

buildandrun:

set projectName to "projectName"
# AppleScript uses : for / in directory paths
set projectDir to "Users:username:Documents:" & projectName & ":" & projectName & ".xcodeproj"
tell application "Xcode"
    open projectDir
    tell project projectName
           clean
           build
           (* for some reasons, debug will hang even the debug process has completed. 
              The try block is created to suppress the AppleEvent timeout error 
            *)
           try
               debug
           end try
    end tell
    quit
end tell

然后,最后,我在.bash_profile中使用名为run.sh别名的shell脚本:

run.sh:

#!/bin/bash

bash utils/sync.sh
osascript utils/buildandrun