xcode 与 jenkins 一起使用的 xcodebuild 测试命令不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13051479/
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-09-15 01:55:43  来源:igfitidea点击:

xcodebuild test command for using with jenkins doesn′t work

iosxcodecommand-linexcode4.5

提问by nicoyuste

I am having one problem that is killing me. Here it is: I have and app project in xCode that goes perfect when I tried to do everything in xCode UI. Which that I mean build, run, test or whatever in all the different targets that I have (3), 2 of the App and one for the tests.

我遇到了一个让我丧命的问题。这是:我在 xCode 中有一个应用程序项目,当我尝试在 xCode UI 中完成所有操作时,它变得完美。我的意思是在我拥有的所有不同目标 (3)、2 个应用程序和一个用于测试的所有不同目标中构建、运行、测试或任何其他内容。

THe problem comes when I tried to install a continous integration to my system in Jenkins. I need to execute some commands in shell for it. Command like this one:

当我尝试在 Jenkins 中为我的系统安装持续集成时,问题就出现了。我需要在 shell 中为它执行一些命令。像这样的命令:

xcodebuild -project MYPROJECT -sdk iphonesimulator -scheme TESTS_SCHEME TEST_AFTER_BUILD=YES

I also have tried with this other one that in the end it does the same:

我也尝试过另一个,最后它也做了同样的事情:

xcodebuild -project MY_PROJECT -target TEST_TARGET -sdk iphonesimulator  -configuration "Debug"

Then is when the problems cames out, the terminal says the following:

然后就是问题出来的时候,终端提示如下:

....PrecompiledHeaders/MYLIBRARY-Prefix-hhjuztynfruquodlgqxroyfibfkh/MYLIBRARY-Prefix.pch.d
clang: error: invalid architecture 'arm' for deployment target '-mios-simulator-version-min=4.3'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1


** BUILD FAILED **


The following build commands failed:
    ProcessPCH /Users/nicoyuste/Library/Developer/Xcode/DerivedData/MY_APP-bxpgsdbefuawmiexyikbtvsatlsf/Build/Intermediates/PrecompiledHeaders/MYLIBRARY-Prefix-hhjuztynfruquodlgqxroyfibfkh/MYLIBRARY-Prefix.pch.pth MYLIBRARY-Prefix.pch normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

I′ve been looking in the Internet (almost in here) but everything what I found with same problem didn′t work for me. The xCode version is 4.5 and if you do xcodebuild -versionis what I get so that′s fine.

我一直在寻找互联网(几乎在这里)但是我发现的所有问题都对我不起作用。xCode 版本是 4.5,如果你做的xcodebuild -version是我得到的,那很好。

I also have tried changing headers files and everything what I have found around but nothing fixes my problem...

我也尝试过更改头文件和我发现的所有内容,但没有解决我的问题......

any suggestions...

有什么建议...

采纳答案by nicoyuste

I am seeing people who is still wondering about this. I posted this question a long time ago. I stopped using xcodebuild and I am using xctoolnow, it works much better. This tool is developed by Facebook.

我看到人们仍然对此感到疑惑。我很久以前发布了这个问题。我停止使用 xcodebuild,现在使用xctool,效果更好。该工具由 Facebook 开发。

回答by Eric Goldberg

If you're using a custom build script, you can pass -arch i386 to xcodebuild

如果您使用自定义构建脚本,则可以将 -arch i386 传递给 xcodebuild

For instance:

例如:

xcodebuild -project MY_PROJECT -target TEST_TARGET -sdk iphonesimulator -configuration "Debug" -arch i386

(Scroll all the way to the right in the code sample above. The relevant flag is -arch i386)

(在上面的代码示例中一直向右滚动。相关标志是-arch i386

Should force it to build against i386. However, you need to make sure i386 is in your VALID_ARCHS settings for the target.

应该强制它针对 i386 构建。但是,您需要确保 i386 在目标的 VALID_ARCHS 设置中。

回答by Jingjie Zhan

In case anyone running into the same annoying problem again, I will share my script here: Remember to run this command under the directory that has the xcodeproj file.

如果有人再次遇到同样烦人的问题,我将在这里分享我的脚本:记住在包含 xcodeproj 文件的目录下运行此命令。

xcodebuild \
-project "full-path-to-your-xcodeproj-file" \
-target YOUR_TARGET \
-sdk iphonesimulator6.1 \
-arch i386 \
-configuration Debug \
VALID_ARCHS="armv6 armv7 i386" \
ONLY_ACTIVE_ARCH=NO \
TARGETED_DEVICE_FAMILY="1" \
clean install

I modified the TARGETED_DEVICE_FAMILY because I only build for iPhone. If you want to build for both iPhone and iPad, delete this line or replace with TARGETED_DEVICE_FAMILY="1, 2".

我修改了 TARGETED_DEVICE_FAMILY 因为我只为 iPhone 构建。如果您想为 iPhone 和 iPad 构建,请删除此行或替换为 TARGETED_DEVICE_FAMILY="1, 2"。

回答by Kiran S

I tried below command: xcodebuild -arch i386 -sdk iphonesimulator7.1 But failed with similar error as clang: error: invalid architecture 'arm' for deployment target '-mios-simulator-version-min=6.0'

我尝试了下面的命令:xcodebuild -arch i386 -sdk iphonesimulator7.1 但失败了与clang类似的错误:错误:部署目标'-mios-simulator-version-min = 6.0'无效架构'arm'

Here is how I solved :

这是我解决的方法:

xcodebuild -arch i386 VALID_ARCHS="i386 armv7 armv7s" ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator7.1

xcodebuild -arch i386 VALID_ARCHS="i386 armv7 armv7s" ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator7.1

U need to make u set VALID_ARCHS and ONLY_ACTIVE_ARCH correctly and it will work. You can make these settings on Xcode directly too.

你需要让你正确设置 VALID_ARCHS 和 ONLY_ACTIVE_ARCH 并且它会起作用。您也可以直接在 Xcode 上进行这些设置。

回答by tkanzakic

I think that the problem reside in that your are building for the simulator specifying arm as the architecture, try changing it to i386

我认为问题在于您正在为模拟器构建指定 arm 作为架构,请尝试将其更改为 i386

回答by gaige

I ran into a similar problem after upgrading to Xcode 4.5 on my build machine. In my case, I have a third-party library that can't be built for armv7s (yet) and so, I set the Architecturesbuild setting to armv7. Worked fine for unit tests, simulator builds, and the like inside of Xcode. However, when I did the command-line build, it failed with the same message.

在我的构建机器上升级到 Xcode 4.5 后,我遇到了类似的问题。就我而言,我有一个无法为 armv7s 构建的第三方库(尚),因此,我将Architectures构建设置设置为armv7. 适用于 Xcode 内部的单元测试、模拟器构建等。但是,当我进行命令行构建时,它失败并显示相同的消息。

I changed my Architecturesto armv7 i386and now it seems to build fine at the command line for the simulator.

我改变了我Architecturesarmv7 i386,现在它似乎在模拟器的命令行上构建得很好。

Despite the GUI indicating that Architectures of Standard (armv7,armv7s)includes just those two, I'm pretty sure there's an i386 hiding there when you build for the simulator.

尽管 GUI 表明 Architectures ofStandard (armv7,armv7s)仅包含这两个,但我很确定当您为模拟器构建时,那里隐藏着一个 i386。

In the end, that setting works fine now with Jenkins.

最后,该设置现在与 Jenkins 一起工作正常。