Skip to content

Instantly share code, notes, and snippets.

@mtitolo
Last active December 18, 2015 17:09
Show Gist options
  • Save mtitolo/f5283c54e300d88d9418 to your computer and use it in GitHub Desktop.
Save mtitolo/f5283c54e300d88d9418 to your computer and use it in GitHub Desktop.
CocoaPods & Pre-Build actions for Xcode CI

To run pod install as a pre-build action for your target using RVM, follow these easy steps.

  1. Duplicate your main scheme, and make sure it's shared
  2. Navigate to the Edit Build section of your new scheme
  3. Uncheck Find Implicit Dependencies (otherwise Xcode will stop the build when the workspace contents change)
  4. Go into the Pre-actions subsection
  5. Add a new run script with the following content:
source "$HOME/.rvm/scripts/rvm"
rvm use ruby-1.9.3-p194 # whichever version of Ruby you installed the cocoapods gem to
cd ${SRCROOT}
pod install
  1. Change the Shell to /usr/bin/env bash and make sure to Provide Build Settings from your target
  2. Click OK
  3. Switch to the new scheme, and build!

To run pod install as a pre-build action for your target using the system Ruby, follow these easy steps.

  1. Duplicate your main scheme, and make sure it's shared
  2. Navigate to the Edit Build section of your new scheme
  3. Uncheck Find Implicit Dependencies (otherwise Xcode will stop the build when the workspace contents change)
  4. Go into the Pre-actions subsection
  5. Add a new run script with the following content:
cd ${SRCROOT}
pod install
  1. Click OK
  2. Switch to the new scheme, and build!

##So you want to use CocoaPods with the new CI stuff in OS X Server?

###Updates for DP4+ Including GM#### Unless you check in your Pods folder, this won't work in DP4+ due to some compiler bugs. See this post on the dev forums which has a link to a summary, and a radar to dupe. Please dupe the radar posted if you would like to use CocoaPods with Bots.

###Instructions < DP4 Unlike other CI systems you may be familiar with, the Xcode CI on OS X Server doesn't have the concept of build steps.

So if you want to run pod install before each build, you need to add it as a pre-build action on your scheme.

These are the instructions for setting this up when you have CocoaPods installed on the system Ruby, and using RVM.

Note: To get this working as of the current state of OS X Server and Xcode 5, your project can no longer find implicit dependencies. You need to explicitly add dependencies to your project. (rdar://14221932)

###Instructions DP4+ You need to check in your Pods folder. If you don't want to do this, please see the dev forum post in the update above.

Copy link

ghost commented Sep 11, 2013

@mtitiolo: Do you have it already tested with the yesterdays released Gold Master?

@ketzusaka
Copy link

I got it working with Find Implicit Dependencies checked. I installed RVM in a multi-user setting, though. You also have to be sure to include environment variables in your build script.

@mtitolo
Copy link
Author

mtitolo commented Oct 3, 2013

@ketzusaka can you post what your settings are? I'm still getting Build Canceled when the workspace contents change.

@Dimillian
Copy link

I just setup a server today, what I got is ld: library not found for -lPods at the end of the build phase, just before launching the simulator...

@mtitolo
Copy link
Author

mtitolo commented Oct 16, 2013

@Dimillian that sounds like the 64-bit architecture problem. Check you have ONLY_ACTIVE_ARCHS=NO

@andrewtheis
Copy link

@mtitolo What's the best way to get this working right now without checking the Pods/ folder? Is it to add the pod install pre-build script? I'm trying to sort through these threads but there doesn't seem to be a definitive answer for Xcode 5.0+

@ketzusaka Interested in your solution as well.

@mtitolo
Copy link
Author

mtitolo commented Oct 23, 2013

@andrewtheis I have some instructions I was sent by someone who got them kind of working, but haven't had the time to try them, and these instructions were posted on the Google Group this AM. If you'd like to take a look/help, ping me michele@cocoapods.org

@jbyung-zz
Copy link

hi @mtitolo has there been any update regarding this issue so far? I'm getting the same issue in XCode 6 (when I attempt to integrate XCode CI in my OSX project. My project is in a workspace and is using cocopods). The only workaround that I've found so far is by committing all the pods files and all the workspace files to the repository in order to get it to build. The pre-action (set up in a scheme) or the before-trigger in the bot doesnt work with "pod install". Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment