Rob Fletcher
Rob Fletcher

Reputation: 8627

Link error attempting to build app with Cocoapods using xcodebuild on Jenkins

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 Debug configuration but I'm struggling to build the IPA as I get a linkage error during compilation.

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.

I searched for similar problems and tried/verified a bunch of things:

At that point I'm at a loss for what more to try.

Upvotes: 14

Views: 6726

Answers (5)

Curt Eckhart
Curt Eckhart

Reputation: 495

I can't speak to the XCode plugin, so my answer may be considered somewhat unresponsive, but here is how I got it working.

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 -destination and -destination-timeout were 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.

If the XCode plugin allows you to state extra compile arguments, you should try these.

Upvotes: 0

Stephanus Mostert
Stephanus Mostert

Reputation: 909

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'

Upvotes: 3

Alexander Yakovlev
Alexander Yakovlev

Reputation: 510

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.

Upvotes: 0

Mojtaba
Mojtaba

Reputation: 6044

The problem might be because you have different (custom) build configurations.

Take a look at this:

https://github.com/CocoaPods/CocoaPods/issues/121

Try adding following search path to "Library Search Paths" (For all configs)

$(SYMROOT)/Release$(EFFECTIVE_PLATFORM_NAME)

Upvotes: 2

apouche
apouche

Reputation: 9983

If you're using XCode 5 then I think this should help

basically update your Gemfile (or create one if it doesn't exist) and add:

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.

Hope this helps, cause it saved me a few days of nightmare.

Upvotes: -2

Related Questions