xcode 尝试在 Jenkins 上使用 xcodebuild 使用 Cocoapods 构建应用程序时出现链接错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18057102/
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
Link error attempting to build app with Cocoapods using xcodebuild on Jenkins
提问by Rob Fletcher
I'm trying to set up a Jenkins CI instance for our app development project. I have jobs working that run logic and application tests using the Debugconfiguration but I'm struggling to build the IPA as I get a linkage error during compilation.
我正在尝试为我们的应用程序开发项目设置一个 Jenkins CI 实例。我有使用Debug配置运行逻辑和应用程序测试的工作,但我正在努力构建 IPA,因为我在编译期间遇到链接错误。
ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The app uses Cocoapods and I'm building with the Jenkins XCode plugin.
该应用程序使用 Cocoapods,我正在使用 Jenkins XCode 插件进行构建。
I searched for similar problems and tried/verified a bunch of things:
我搜索了类似的问题并尝试/验证了很多事情:
- I am using a workspace.
- I'm running
pod install
before the xcodebuild step. - I've checked that architectures on the project itself, the target and Pods are the same – standard (armv7, armv7s)–?as suggested by this answer
- I tried various solutions from this GitHub thread
- I tried various settings for Derived Datalocations as per this answerand similar ones
- The Podfile specifies
platform :ios, :deployment_target => "6.0"
- 我正在使用工作区。
- 我
pod install
在 xcodebuild 步骤之前运行。 - 我已经检查过项目本身的架构,目标和Pod是相同的——标准(armv7,armv7s)——?正如这个答案所建议的
- 我从这个 GitHub 线程尝试了各种解决方案
- 我根据这个答案和类似的答案尝试了衍生数据位置的各种设置
- Podfile 指定
platform :ios, :deployment_target => "6.0"
At that point I'm at a loss for what more to try.
在这一点上,我不知道还有什么可以尝试的。
回答by Stephanus Mostert
The 'Build Output Directory' setting can also cause this.
“构建输出目录”设置也可能导致这种情况。
Changing the value of the 'Build Output Directory' from a relative path to a fully specified path fixed it for me.
将“构建输出目录”的值从相对路径更改为完全指定的路径为我修复了它。
E.g. instead of 'MyOutputDirectory' use '/Users/Shared/Jenkins/home/jobs/JenkinsProject/workspace/MyOutputDirectory'
例如,使用“/Users/Shared/Jenkins/home/jobs/JenkinsProject/workspace/MyOutputDirectory”代替“MyOutputDirectory”
回答by Mojtaba
The problem might be because you have different (custom) build configurations.
问题可能是因为您有不同的(自定义)构建配置。
Take a look at this:
看看这个:
https://github.com/CocoaPods/CocoaPods/issues/121
https://github.com/CocoaPods/CocoaPods/issues/121
Try adding following search path to "Library Search Paths" (For all configs)
尝试将以下搜索路径添加到“库搜索路径”(对于所有配置)
$(SYMROOT)/Release$(EFFECTIVE_PLATFORM_NAME)
回答by Alexander Yakovlev
You can try choose your Pods project and set Build Settings->Build Active Architectures Only->NO for Release and Debug, repeat this action for each target in Pods.
您可以尝试选择您的 Pods 项目并设置 Build Settings->Build Active Architectures Only->NO for Release and Debug,对 Pods 中的每个目标重复此操作。
回答by Curt Eckhart
I can't speak to the XCode plugin, so my answer may be considered somewhat unresponsive, but here is how I got it working.
我无法使用 XCode 插件,所以我的回答可能被认为有点反应迟钝,但这是我如何让它工作的。
I added a build step that looks like this:
我添加了一个如下所示的构建步骤:
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer/
echo $WORKSPACE
cd "/Users/[jenkins-accountname]/.jenkins/jobs/[jobname]/workspace/[xcode project name]"
pod install
xcrun xcodebuild -workspace [your workspace (not project) name] -scheme [the build scheme to build] clean build -destination "platform=iOS,name=CurtsiPhone" -destination-timeout 120
The -destinationand -destination-timeoutwere key build arguments for success. My project will only build on the phone since it uses specialized libraries, so my phone has to be plugged in so the XCode can find it. You may not need this if your project will build in the simulator, however I only got it working when I explicitly specified a destination.
该-destination和-destination超时是成功的关键构建参数。我的项目只会在手机上构建,因为它使用专门的库,所以我的手机必须插入,以便 XCode 可以找到它。如果您的项目将在模拟器中构建,则您可能不需要它,但是我只有在明确指定目标时才能使其工作。
If the XCode plugin allows you to state extra compile arguments, you should try these.
如果 XCode 插件允许您声明额外的编译参数,您应该尝试这些。
回答by apouche
If you're using XCode 5 then I think thisshould help
如果您使用的是 XCode 5,那么我认为这应该会有所帮助
basically update your Gemfile (or create one if it doesn't exist) and add:
基本上更新您的 Gemfile(如果它不存在,则创建一个)并添加:
gem 'cocoapods', :git => 'http://github.com/CocoaPods/CocoaPods', :branch => 'xcode-5-support'
gem 'xcodeproj', :git => 'http://github.com/CocoaPods/Xcodeproj', :branch => 'redacted-support'
Also if you have things like config.build_settings['ARCHS'] = 'armv7'
in your Podfile, don't forget to get rid of it, you'll need to have armv7s too.
此外,如果您config.build_settings['ARCHS'] = 'armv7'
的 Podfile 中有类似内容,请不要忘记删除它,您也需要拥有 armv7s。
Hope this helps, cause it saved me a few days of nightmare.
希望这会有所帮助,因为它为我节省了几天的噩梦。