我正在尝试使用Jenkins CI(在带有Mavericks的Mac Mini上)使用xcodebuild
命令来构建我的iOS项目。
我玩了好几个小时,但无法解决这个问题。
以下命令在命令行上构建我的项目没有任何问题,但在Jenkins中运行时失败。
xcodebuild -workspace ./MyProject.xcworkspace
-scheme MyProject
-configuration AdHoc
-sdk iphoneos
DSTROOT=/Users/me/myproject
OBJROOT=/Users/me/myproject
SYMROOT=/Users/me/myproject
ONLY_ACTIVE_ARCH=NO
OTHER_CODE_SIGN_FLAGS="--keychain /Users/me/Library/Keychains/temporary.keychain"
(为了清晰起见,添加了换行符。)
错误总是如下所示:
CompileC /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/Objects-normal/armv7/SomeViewController.o MyProject/Code/Controllers/Event/SomeViewController.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/me/.jenkins/jobs/myproject/workspace
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-cache-path=/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache -Wno-trigraphs -fpascal-strings -Os -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DCOCOAPODS=1 -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/MyProject-generated-files.hmap -I/Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/MyProject-own-target-headers.hmap -I/Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/MyProject-all-target-headers.hmap -iquote /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/MyProject-project-headers.hmap -I/Users/me/myproject/AdHoc-iphoneos/include -I/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers -I/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers/AFNetworking -I/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers/SDWebImage -I/Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/DerivedSources/armv7 -I/Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/DerivedSources -F/Users/me/myproject/AdHoc-iphoneos -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -isystem/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers -isystem/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers/AFNetworking -isystem/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers/SDWebImage -include /Users/me/Library/Developer/Xcode/DerivedData/MyProject-gyrrispdpuygvudbmupzhfzzaaag/Build/Intermediates/PrecompiledHeaders/MyProject-Prefix-asaxoaokmbdwezcdrhupsyxzhzrl/MyProject-Prefix.pch -MMD -MT dependencies -MF /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/Objects-normal/armv7/SomeViewController.d --serialize-diagnostics /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/Objects-normal/armv7/SomeViewController.dia -c /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Controllers/Event/SomeViewController.m -o /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/Objects-normal/armv7/SomeViewController.o
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Controllers/Event/SomeViewController.m:9:
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Controllers/Event/SomeViewController.h:10:
/Users/me/.jenkins/jobs/myproject/workspace/Pods/Headers/SDWebImage/UIImageView+WebCache.h:1:1: error: expected identifier or '('
../../SDWebImage/SDWebImage/UIImageView+WebCache.h
^
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Controllers/Event/SomeViewController.m:9:
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Controllers/Event/SomeViewController.h:11:
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Models/SomeEvent.h:10:
In file included from /Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Models/SomeRoom.h:10:
/Users/me/.jenkins/jobs/myproject/workspace/MyProject/Code/Models/ABKBuilding.h:14:1: error: unexpected '@' in program
@property (nonatomic, strong) NSString *buildingID;
^
[... a lot more of this]
** BUILD FAILED **
The following build commands failed:
CompileC /Users/me/myproject/MyProject.build/AdHoc-iphoneos/MyProject.build/Objects-normal/armv7/SomeViewController.o MyProject/Code/Controllers/SomeViewController.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Build step 'Execute shell' marked build as failure
到目前为止我做了什么:
xcode-select
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
命令xcodebuild
修改 我忘了提到这个项目使用的是CocoaPods,不确定这可能是它不能构建的原因。
编辑2:我添加了一些错误输出。我正在检查我的Pods文件夹到git。同一个项目在命令行上没有任何问题。命令完全没有区别,我三重检查。 不幸的是,由于各种自定义原因,我无法使用Xcode插件。但即使我可以,我也想知道两种环境之间的区别。
更新:我似乎无法编译项目中的某些.m文件,输出总是从一个构建到另一个构建有点不同。我还在我的构建方案中添加了一个依赖项,以确保在其他任何东西之前构建CocoaPods。
仍然不知道为什么有些文件导致了这个问题。
有人可以确认他们仍然可以使用xcodebuild Xcode 5.1 Build version 5B130a
从Jenkins构建项目吗?
答案 0 :(得分:1)
我正在使用 Xcode 5.0.2(5A3005),我也在命令行中使用xcodebuild
构建,而不使用Jenkins插件或IDE。
一个注意事项:Jenkins为每个构建步骤创建了一组新的环境变量。在某个构建步骤中创建的任何新环境变量都不会在下一个构建步骤中复制。有办法(但目前不是你的问题)。如果您的export
命令在xcodebuild
命令的单独执行Shell 构建步骤中运行,那么它就没有任何影响。
这是尝试的事情:
在命令行上,键入xcode-select -p
然后输入set
复制将输出粘贴到可以差异的好文本编辑器
然后运行Jenkins作业,并在执行销售构建步骤中,使用相同的命令:
xcode-select -p
set
复制将输出粘贴到一个好的文本编辑器,然后将这两个文件区分开来。
首先,比较xcode-select -p
的输出是相同的
然后,除了Jenkins执行中的额外变量(例如$BUILD_NUMBER
等)之外,应该没有差异。