从终端构建/运行 iOS Xcode 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7486326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 21:34:55  来源:igfitidea点击:

Build/run iOS Xcode project from Terminal

iosxcodemacostestingterminal

提问by Lkm

I want to build a Xcode project from Terminal and then run it as required, also from Terminal.

我想从终端构建一个 Xcode 项目,然后根据需要运行它,也从终端运行。

I have been looking for a way to do this for a while now but only managed to find a method which works for the iPhone Simulator, not for the actual device it self.

我一直在寻找一种方法来做到这一点,但只是设法找到了一种适用于 iPhone 模拟器的方法,而不是适用于它本身的实际设备。

Is this even possible? The reason I want to a Xcode project on a device from Terminal is because the application runs a series of automated tests and I would prefer to automate this process using a bash script.

这甚至可能吗?我想从终端在设备上创建 Xcode 项目的原因是该应用程序运行一系列自动化测试,我更喜欢使用 bash 脚本自动化此过程。

Thanks

谢谢

回答by bandejapaisa

To build your xcode project from the command line using a bash script use:

要使用 bash 脚本从命令行构建您的 xcode 项目,请使用:

/usr/bin/xcodebuild -target TargetYouWantToBuild -configuration Debug

Look at the man page for xcodebuild for more options.

查看 xcodebuild 的手册页以获取更多选项。

We do this for our unit test suite target, and we use GHUnit.

我们为单元测试套件目标执行此操作,并使用 GHUnit。

This is the section of our build script for running the tests:

这是用于运行测试的构建脚本部分:

export GHUNIT_CLI=1
export WRITE_JUNIT_XML=1
clean
echo "Building Bamboo GHUnit Tests..."
OUTPUT=`/usr/bin/xcodebuild -target BambooAutomatedUnitTest -configuration Debug -sdk iphonesimulator4.3 build`
RESULT=`echo "$OUTPUT" | grep "\*\* BUILD "`
if [ "$RESULT" != "** BUILD SUCCEEDED **" ]
then
    echo "$OUTPUT"
    exit 1
fi
echo "${RESULT}\n"